c++ - Arduino can't get my boolean to work -
i cant boolean work don't know i'm doing wrong it. take @ code , give me hint on wrong it? have tested different ways write without success. time boolean worked when put code under void loop. can't use there.
#include <remotereceiver.h> boolean statusled1 = false; void setup() { serial.begin(115200); // initialize receiver on interrupt 0 (= digital pin 2), calls callback "showcode" // after 3 identical codes have been received in row. (thus, keep button pressed // moment) // // see interrupt-parameter of attachinterrupt possible values (and pins) // connect receiver. remotereceiver::init(0, 3, showcode); } void loop() { } // callback function called when valid code received. void showcode(unsigned long receivedcode, unsigned int period) { // note: interrupts disabled. can re-enable them if needed. // print received code. serial.print("code: "); serial.print(receivedcode); serial.print(", period duration: "); serial.print(period); serial.println("us."); if (receivedcode == 353805) { statusled1 = true; } if (receivedcode == 352829) { statusled1 = false; } if (statusled1 = true) { serial.print("on"); } if (statusled1 = false){ serial.print("off"); } }
if (statusled1 = true) {
oldest gotcha in book. =
assignment, ==
equality comparison.
also, don't compare against boolean regardless.
if (statusled1) {
Comments
Post a Comment