niec eye. now you can scare away burglars:D
Printable View
niec eye. now you can scare away burglars:D
The Arduino will only run one loop but what you can do is have it poll the temp and adjust the fins and once its finished it can scan the room. Just set a delay of like 100 between the 2 and it should work. Let me see if I can work up a code real quick.
You could do something like this with servo #2 being the one the eye is attached to.
Code:// Controlling a servo position using a temperature sensor
// by Michal Rinott <http://people.interaction-ivrea.it/m.rinott>
// edited 5-12-2010 by Will Lyon to include base setting for servo if voltage not detected on pin 7
//edited 6-2-2010 by Charles Gantt to include second servo scanning control
#include <Servo.h>
#define CONTROL 7
Servo myservo; // create servo object to control a servo
Servo servo2; // creates servo object number 2
int temps = 0; // analog pin used to connect the temp sensor
int val; // variable to read the value from the analog pin
int pos = 0; // variable to store the servo position
void setup()
{
pinMode (CONTROL, INPUT); // sets the control pin to input
myservo.attach(9); // attaches the servo on pin 9 to the servo object
servo2.attach(11); // attaches servo #2 on pin 11 to the servo object
digitalWrite(CONTROL, LOW); // ensure internal pullup resistor is disabled.
}
void loop()
{
val = digitalRead(CONTROL); //read input of pin 7 and store it
if (val == HIGH){ // reads whether or not 5v is present on pin 7, if 5v present, continue:
val = analogRead(temps); // reads the value of the temp sensor (value between 0 and 1023)
val = map(val, 350, 700, 75, 105); // scale it to use it with the servo (value between 0 and 180)
myservo.write(val); // sets the servo position according to the scaled value
delay(25); // waits for the servo to get there
} else {
if (val == LOW); // if no voltage present on pin 7, continue
myservo.write(50); //sets servo position to 50 if no voltage is detected on pin 7
}
delay(25); // waits for the servo to get there
{
delay(100); //delay between functions
for(pos = 0; pos < 180; pos += 1); // goes from 0 degrees to 180 degrees
{ // in steps of 1 degree
servo2.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position
}
for(pos = 180; pos>=1; pos-=1); // goes from 180 degrees to 0 degrees
{
servo2.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position
}
}
}
I'll have to hook up a second servo and try that out. should be neat :D thanks! +rep
:edit: gotta spread some rep first lol
I just edited the code.
I'll have to mess around with that tonight! still hoping I hear from the waterjet guy today so I can get some work done this weekend!
Oneslowz28 Edit: I hit the edit button instead of the quote button.:facepalm:
I will be on MSN all night so hit me up if you want to talk geek while you dev.
msn chat? I don't have it but I can install it on my temporary (read components resting on top of a carboard box) basement comp
I just got off the phone with Tom over @ HydroCutter and he said he's still doing the production run he had before me, and the machine had developed a leak that he had to fix, so he's hoping to have my parts done for Tuesday-ish (fingers crossed)
That sucks but at least you can have fun deving with arduino.
My MSN is charlesgantt at live dot com