Files
buzzer/sketch_may21a/sketch_may21a.ino
Malin Freeborn 7278ca3460 write buzzer code
This code still has errors, but I can't code, so it's your problem
now.
2024-05-21 21:06:53 +02:00

31 lines
489 B
C++

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