I've been trying to figure out how to make my Arduino nano use a buzzer to beep when the sensor value reaches 1023 but I haven't been able to get it set up. Any help would be appreciated. Here's my code:
// Include the library code:
#include <LiquidCrystal.h>
// Initialize the library with the numbers of the
// UNO interface pins.
// Syntax: LiquidCrystal(rs, enable, d4, d5, d6, d7)
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
#define buzzer 13
//#define MQ3pin 0
float sensorValue; //variable to store sensor value
void setup() {
lcd.begin(20, 4);
pinMode(13, OUTPUT);
//lcd.print("MQ3 warming up!");
//delay(20000); // allow the MQ3 to warm up
//if (sensorValue = 1023) {tone( buzzer, 3000);}
//if {digitalWrite(ledPin, {tone( buzzer, 3000);});};
//else { };
}
void loop() {
sensorValue = analogRead(0); // read analog input pin 0
if (analogRead > 1022)
lcd.setCursor (0,0);
lcd.print ("250-510: no alc");
lcd.setCursor (0,1);
lcd.print ("511-1022 Mod alc");
lcd.setCursor (0,2);
lcd.print ("flash 1023: high alc");
lcd.setCursor (0,3);
lcd.print("Alc level: ");
lcd.print(sensorValue);
delay(2000); // wait 2s for next reading
lcd.clear();
}