write buzzer code

This code still has errors, but I can't code, so it's your problem
now.
This commit is contained in:
Malin Freeborn 2024-05-21 21:06:53 +02:00
parent e3909e34f0
commit 7278ca3460
Signed by: andonome
GPG Key ID: 52295D2377F4D70F

View 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);
}