Being that we are two individuals with little experience (none, actually) when it comes to coding, Arduinos and sensors, this is an extremely intimidating realm to enter into. Thankfully, once again, the internet is our friend, this time in the form of Dave Giancaspro's article on Wired.com. He was creating some kind of motion-triggered, heart-attack-giving halloween decoration. I bet he would be disappointed that we are using his code to take pretty pictures of Hummingbirds.
Anyway.
Thanks to him we had this code:
int motion_1 = 2;int light_1 = 13;void setup(){ pinMode (motion_1,INPUT); pinMode (light_1, OUTPUT);}void loop (){ digitalWrite (light_1,LOW); delay(1000); //this delay is to let the sensor settle down before taking a reading int sensor_1 = digitalRead(motion_1);\ if (sensor_1 == HIGH){ digitalWrite(light_1,HIGH); delay(500); digitalWrite(light_1,LOW); delay(500); }}
Next, plug in a few wires, the sensor, and an LED, and BLAMMO! We now have an LED light that flashes when the motion sensor has been tripped.
No comments:
Post a Comment