Created
December 25, 2020 13:45
-
-
Save donly/6364ef50184d5aed558c355ecea01e8d to your computer and use it in GitHub Desktop.
Photoresistor and buzzer usage demo
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define BUZZER D6 | |
#define LIGHTD D11 | |
void setup() { | |
Serial.begin(115200); | |
Serial.println("setup"); | |
pinMode(BUZZER, OUTPUT); | |
digitalWrite(BUZZER, HIGH); | |
pinMode(LIGHTD, INPUT); | |
} | |
void loop() { | |
if (digitalRead(LIGHTD)) { | |
buzzer_Di(); | |
} | |
else { | |
buzzer_off(); | |
} | |
} | |
void buzzer_Di() { | |
Serial.println("Bi..ON"); | |
digitalWrite(BUZZER, LOW); | |
delay(300); | |
} | |
void buzzer_off() { | |
Serial.println("Bi..OFF"); | |
digitalWrite(BUZZER, HIGH); | |
delay(300); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment