Browse Source

Replace speaker with buzzer

master
Burathar 4 years ago
parent
commit
f532432d8b
  1. 14
      smoker.ino

14
smoker.ino

@ -48,6 +48,9 @@ Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);
Queue tempQueue; Queue tempQueue;
void setup() { void setup() {
pinMode(SPEAKER_PIN, OUTPUT);
digitalWrite(SPEAKER_PIN, LOW);
//Serial.begin(9600); //Serial.begin(9600);
if (!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { if (!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
//Serial.println(F("SSD1306 allocation failed")); //Serial.println(F("SSD1306 allocation failed"));
@ -117,12 +120,15 @@ void updateRelay(){
int second = millis() % 1000; int second = millis() % 1000;
if (alarmState == 0 and second < 100) { if (alarmState == 0 and second < 100) {
alarmState = 1; alarmState = 1;
tone(SPEAKER_PIN, 440, 400); digitalWrite(SPEAKER_PIN, HIGH);
} } else if (alarmState == 1 and second > 500 and second < 600) {
if(alarmState == 1 and second > 500 and second < 600){
alarmState = 0; alarmState = 0;
tone(SPEAKER_PIN, 554, 400); digitalWrite(SPEAKER_PIN, LOW);
} else if (alarmState == -1) {
digitalWrite(SPEAKER_PIN, LOW);
} }
} else {
digitalWrite(SPEAKER_PIN, LOW);
} }
} }

Loading…
Cancel
Save