Motion sensor pet water fountain to avoid choking
Автор: Tim Fitzgerald
Загружено: 2023-09-24
Просмотров: 119
Designed to switch on, and then off while disabling the motion sensor trigger for a period of time to prevent the cat from choking on too much water.
const int motionPin = 2; // the pin number of the motion sensor
const int outputPin = 3; // the pin number of the output device
const int onTime = 10000; // the time in milliseconds that the output device should be on
const int restTime = 8000; // the time in milliseconds that the output device should be off before checking the sensor again
void setup() {
pinMode(motionPin, INPUT); // set the motion sensor pin as an input
pinMode(outputPin, OUTPUT); // set the output device pin as an output
}
void loop() {
if (digitalRead(motionPin) == HIGH) { // check if motion is detected
digitalWrite(outputPin, HIGH); // turn on the output device
delay(onTime); // wait for the specified on time
digitalWrite(outputPin, LOW); // turn off the output device
delay(restTime); // disable for the specified on time
}
}
Доступные форматы для скачивания:
Скачать видео mp4
-
Информация по загрузке: