write buzzer code
This code still has errors, but I can't code, so it's your problem now.
This commit is contained in:
parent
e3909e34f0
commit
7278ca3460
30
sketch_may21a/sketch_may21a.ino
Normal file
30
sketch_may21a/sketch_may21a.ino
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
const int requestEnterPin = 36;
|
||||||
|
const int openDoorPin = 32;
|
||||||
|
int requestvalue;
|
||||||
|
|
||||||
|
// setup code runs once:
|
||||||
|
void setup() {
|
||||||
|
pinMode(requestEnterPin, INPUT);
|
||||||
|
pinMode(openDoorPin, OUTPUT);
|
||||||
|
}
|
||||||
|
|
||||||
|
void openDoor() {
|
||||||
|
analogWrite(openDoorPin, 255);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool askToOpen() {
|
||||||
|
requestvalue = analogRead(requestEnterPin);
|
||||||
|
if ( requestvalue > 100 ) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// main code runs repeatedly:
|
||||||
|
void loop() {
|
||||||
|
if ( askToOpen() ) {
|
||||||
|
openDoor();
|
||||||
|
}
|
||||||
|
delay(1);
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user