CAN YOU EXPLAIN ME WHY IT ISN'T WORKING?!?!?


hi, want able or disable buzzer press button. post code:
#include <newtone.h>

#include <boarddefs.h>
#include <irremote.h>
#include <irremoteint.h>
#include <ir_lego_pf_bitstreamencoder.h>

#include <irremote.h>
#define flechas 0xff9867
#define usd 0xffb04f
const int buttonpin = 7;
const int speakerpin = 8;
int buttonstate = 0;
int alarmaon;
int led = 6;
int recv_pin = 9; //declaramos el pin que recibira la señal
irrecv irrecv(recv_pin);
decode_results results;

void setup() {
  pinmode(speakerpin, output);
  pinmode(buttonpin, input);
  serial.begin(9600);
  irrecv.enableirin();
  pinmode(led, output);

}

void loop() {
  if (irrecv.decode(&results)) {
    serial.println(results.value, hex);
    if (results.value == flechas) {
      alarmaon = true;
      digitalwrite(led, high);
    }
    if (results.value == usd) {
      alarmaon = false;
      digitalwrite(led, low);
    }

    irrecv.resume();
    delay(10);
  }

  buttonstate = digitalread(buttonpin);
 
  if (alarmaon = true) {
    if (buttonstate == high) {
      nonewtone(speakerpin);
      delay(200);
      newtone(speakerpin, 440, 200);
      delay(200);
    }
    else {
      nonewtone(speakerpin);
    }
  }
  else {
    nonewtone(speakerpin);
  }
}




why isnt works?? thank you.

code: [select]

 if (alarmaon = true)


wrong, unless, of course, want set alarmaon true test value


Arduino Forum > Using Arduino > Programming Questions > CAN YOU EXPLAIN ME WHY IT ISN'T WORKING?!?!?


arduino

Comments

Popular posts from this blog

Error compiling for board Arduino/Genuino Uno.

Installation database is corrupt

esp8266 (nodemcu 0.9) client.write très lent ???