Skip to content

Instantly share code, notes, and snippets.

@SLOLNE
Created March 2, 2016 19:30
Show Gist options
  • Save SLOLNE/b4bfd0796d30252d1b24 to your computer and use it in GitHub Desktop.
Save SLOLNE/b4bfd0796d30252d1b24 to your computer and use it in GitHub Desktop.
Code provided by Tinkernut
http://www.tinkernut.com/2014/03/arduino-motion-detecting-squirt-gun/
We didnt change anything in this code
const int pirPower = 13;
const int pirIn = 12;
int motorPin1 = 3;
void setup(){
pinMode(pirPower, OUTPUT);
pinMode(pirIn, INPUT);
pinMode(motorPin1, OUTPUT);
digitalWrite(motorPin1, LOW);
digitalWrite(pirPower, HIGH);
}
void loop(){
int value= digitalRead(pirIn);
if (value == HIGH){
digitalWrite(motorPin1, HIGH);
delay(500);
digitalWrite(motorPin1, LOW);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment