Compile error with relay example
-
I'm writing a sketch with the 1.5 version of MySensors and based on the relay example that's on this site. When I compile I get a lot of errors about stuff not being declared. I'm assuming that the example on the site is correct. What am I missing here?
The compile errors:
Arduino: 1.6.4 (Windows 8.1), Board: "LilyPad Arduino, ATmega328" In file included from C:\Users\Sebastiaan\Documents\Arduino\libraries\MySensors\MyGateway.cpp:12:0: C:\Users\Sebastiaan\Documents\Arduino\libraries\MySensors\MyGateway.h:39:28: error: 'DEFAULT_CE_PIN' was not declared in this scope MyGateway(uint8_t _cepin=DEFAULT_CE_PIN, uint8_t _cspin=DEFAULT_CS_PIN, uint8_t _inclusion_time = 1, uint8_t _inclusion_pin = 3, uint8_t _rx=6, uint8_t _tx=5, uint8_t _er=4); ^ C:\Users\Sebastiaan\Documents\Arduino\libraries\MySensors\MyGateway.h:39:59: error: 'DEFAULT_CS_PIN' was not declared in this scope MyGateway(uint8_t _cepin=DEFAULT_CE_PIN, uint8_t _cspin=DEFAULT_CS_PIN, uint8_t _inclusion_time = 1, uint8_t _inclusion_pin = 3, uint8_t _rx=6, uint8_t _tx=5, uint8_t _er=4); ^ C:\Users\Sebastiaan\Documents\Arduino\libraries\MySensors\MyGateway.cpp: In constructor 'MyGateway::MyGateway(uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t)': C:\Users\Sebastiaan\Documents\Arduino\libraries\MySensors\MyGateway.cpp:27:167: error: no matching function for call to 'MySensor::MySensor(uint8_t&, uint8_t&)' MyGateway::MyGateway(uint8_t _cepin, uint8_t _cspin, uint8_t _inclusion_time, uint8_t _inclusion_pin, uint8_t _rx, uint8_t _tx, uint8_t _er) : MySensor(_cepin, _cspin) { ^ C:\Users\Sebastiaan\Documents\Arduino\libraries\MySensors\MyGateway.cpp:27:167: note: candidates are: In file included from C:\Users\Sebastiaan\Documents\Arduino\libraries\MySensors\MyGateway.h:15:0, from C:\Users\Sebastiaan\Documents\Arduino\libraries\MySensors\MyGateway.cpp:12: C:\Users\Sebastiaan\Documents\Arduino\libraries\MySensors\MySensor.h:145:2: note: MySensor::MySensor(MyTransport&, MyHw&) MySensor(MyTransport &radio =*new MyTransportNRF24(), MyHw &hw=*new MyHwDriver() ^ C:\Users\Sebastiaan\Documents\Arduino\libraries\MySensors\MySensor.h:145:2: note: no known conversion for argument 1 from 'uint8_t {aka unsigned char}' to 'MyTransport&' C:\Users\Sebastiaan\Documents\Arduino\libraries\MySensors\MySensor.h:136:7: note: MySensor::MySensor(const MySensor&) class MySensor ^ C:\Users\Sebastiaan\Documents\Arduino\libraries\MySensors\MySensor.h:136:7: note: candidate expects 1 argument, 2 provided C:\Users\Sebastiaan\Documents\Arduino\libraries\MySensors\MyGateway.cpp: In member function 'void MyGateway::begin(rf24_pa_dbm_e, uint8_t, rf24_datarate_e, void (*)(char*))': C:\Users\Sebastiaan\Documents\Arduino\libraries\MySensors\MyGateway.cpp:41:20: error: 'setupRepeaterMode' was not declared in this scope setupRepeaterMode(); ^ C:\Users\Sebastiaan\Documents\Arduino\libraries\MySensors\MyGateway.cpp:78:39: error: 'setupRadio' was not declared in this scope setupRadio(paLevel, channel, dataRate); ^ C:\Users\Sebastiaan\Documents\Arduino\libraries\MySensors\MyGateway.cpp:79:36: error: 'BASE_RADIO_ID' was not declared in this scope RF24::openReadingPipe(WRITE_PIPE, BASE_RADIO_ID); ^ C:\Users\Sebastiaan\Documents\Arduino\libraries\MySensors\MyGateway.cpp:81:23: error: cannot call member function 'void RF24::startListening()' without object RF24::startListening(); ^ Error compiling. This report would have more information with "Show verbose output during compilation" enabled in File > Preferences.And the sketch
#include <Adafruit_NeoPixel.h> #ifdef __AVR__ #include <avr/power.h> #endif // MySensors #include <MySigningNone.h> #include <MyTransportNRF24.h> #include <MyHwATMega328.h> #include <MySensor.h> #include <SPI.h> MyTransportNRF24 radio(RF24_CE_PIN, RF24_CS_PIN, RF24_PA_LEVEL_GW); MyHwATMega328 hw; MySensor gw(radio, hw); // Initialize leds #define ledPin 8 #define numPixels 24 Adafruit_NeoPixel strip = Adafruit_NeoPixel(24, ledPin, NEO_GRB + NEO_KHZ400); int pinOff = 3; int pinWhite = 4; int pinRed = 5; int pinGreen = 6; int pinBlue = 7; int power = 0; void setup() { Serial.begin(9600); pinMode(pinOff, INPUT); pinMode(pinWhite, INPUT); pinMode(pinRed, INPUT); pinMode(pinGreen, INPUT); pinMode(pinBlue, INPUT); strip.begin(); // Turn light off strip.show(); Serial.println("Led light ready"); Serial.print("Power is: "); Serial.println(power); } void loop() { int off = digitalRead(pinOff); int white = digitalRead(pinWhite); int red = digitalRead(pinRed); int green = digitalRead(pinGreen); int blue = digitalRead(pinBlue); if(off == 0) { //Off button pushed Serial.println("Off button pushed"); turnOff(); delay(2000); } if(white == 0) { Serial.println("White button pushed"); turnWhite(); delay(2000); } if(red == 0) { Serial.println("Red button pushed"); turnRed(); delay(2000); } if(green == 0) { Serial.println("Green button pushed"); turnGreen(); delay(2000); } if(blue == 0) { Serial.println("Blue button pushed"); turnBlue(); delay(2000); } } void turnOff() { Serial.println("Turning lights of"); strip.setBrightness(0); strip.show(); } void turnWhite() { Serial.println("Setting light to white"); for(int i=0;i<numPixels;i++) { strip.setPixelColor(i, 255, 255, 255); } strip.setBrightness(255); strip.show(); } void turnRed() { Serial.println("Setting light to red"); for(int i=0;i<numPixels;i++) { strip.setPixelColor(i, 255, 0, 0); } strip.setBrightness(255); strip.show(); } void turnGreen() { Serial.println("Setting light to green"); for(int i=0;i<numPixels;i++) { strip.setPixelColor(i, 0, 255, 0); } strip.setBrightness(255); strip.show(); } void turnBlue() { Serial.println("Setting light to blue"); for(int i=0;i<numPixels;i++) { strip.setPixelColor(i, 0, 0, 255); } strip.setBrightness(255); strip.show(); }
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login