Skip to content

Instantly share code, notes, and snippets.

@jrmedd
Last active May 16, 2020 10:50
Show Gist options
  • Save jrmedd/5516863 to your computer and use it in GitHub Desktop.
Save jrmedd/5516863 to your computer and use it in GitHub Desktop.
Replace '#include "WProgram.h"' with this code to make libraries compatible with latest Arduino IDE.
#if defined(ARDUINO) && ARDUINO >= 100
#include "Arduino.h"
#else
#include "WProgram.h"
#endif
#include <Wire.h>
/*Replace #include "WProgram.h" with the above code to make compatible with
latest Arduino IDE.*/
@MarcoV4553
Copy link

Yea this only worked when I deleted the #include "wm_crypto.h". Should I be getting this from somewhere else?

@jrmedd
Copy link
Author

jrmedd commented Nov 8, 2017

Totally missed all of these comments until I dug up this gist recently to fix an old project. I pasted this straight over from a sketch at the time, apologies.

@AlmamyAZ
Copy link

Hi everyone , I've tried this tips , but I have the same problem with WProgram , can you help me ?

Thanks

the .h code

#ifndef LED_h
#define LED_h
#if defined(ARDUINO) && ARDUINO >= 100
#include "Arduino.h"
#else
#include "WProgram.h"
#endif

class LED{
public:
LED(int);
LED(int,int,int,int);
void lightOnBaguette(int);
void lightOffBaguette();
void lightOnCadre(int);
void lightOffCadre();
private:
int ledBaguette; //variable membre pour segment LED Baguette
int ledCadre1; //variable membre pour segment LED Cadre
int ledCadre2;
int ledCadre3;
int ledCadre4;
int luminosite; //variable membre pour la luminosité
};
#endif

and the .cpp code

#if defined(ARDUINO) && ARDUINO >= 100
#include "Arduino.h"
#else
#include "WProgram.h"
#endif
#include "LED.h"

LED::LED(int baguette){
ledBaguette = baguette;
pinMode(ledBaguette, OUTPUT);
}

LED::LED( int cadre1, int cadre2, int cadre3, int cadre4){
ledCadre1 = cadre1;
ledCadre2 = cadre2;
ledCadre3 = cadre3;
ledCadre4 = cadre4;
pinMode(ledCadre1, OUTPUT);
pinMode(ledCadre2, OUTPUT);
pinMode(ledCadre3, OUTPUT);
pinMode(ledCadre4, OUTPUT);
}

void LED::lightOnBaguette(int luminosite){
analogWrite(ledBaguette,luminosite);
}

void LED::lightOnCadre(int luminosite){
analogWrite(ledCadre1,luminosite);
analogWrite(ledCadre2,luminosite);
analogWrite(ledCadre3,luminosite);
analogWrite(ledCadre4,luminosite);
}

void LED::lightOffBaguette(){
digitalWrite(ledBaguette,LOW);
}

void LED::lightOffCadre(){
digitalWrite(ledCadre1,LOW);
digitalWrite(ledCadre2,LOW);
digitalWrite(ledCadre3,LOW);
digitalWrite(ledCadre4,LOW);
}

@pramitbiswas
Copy link

@AlmamyAZ if still the problem exist,
try changing "Arduino.h" "WProgram.h" to <Arduino.h> <WProgram.h>, and removing

#if defined(ARDUINO) && ARDUINO >= 100
#include "Arduino.h"
#else
#include "WProgram.h"
#endif

part from .cpp file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment