Spade, this is the code I used. I’m not sure how to format it correctly for the comments so if you want me to email it to me, let me know.
I built one to “cure” the dog from getting into things I leave accessible by mistake when I leave the house. It’s going to make an appearance at work after the dog learns.
;)
Chris
// BETA version of the Oh Fudge!
int x = A0; // Set X axis pin
int y = A1; // Set Y axis pin
int z = A2; // Set Z axis pin
int xval = 0; // Initial X axis value
int yval = 0; // Initial Y axis value
int zval = 0; // Initial Z axis value
int result1 = 0; // Variable for sum of all three
int result2 = 0; // Varialbe for to compare to
int result_diff = 0; // Variable for the difference
int threshold = 30; // Variable for threshold
void setup() {
pinMode(A0, INPUT); // Set X axis pin as an analog input
pinMode(A1, INPUT); // Set Y axis pin as an analog input
pinMode(A2, INPUT); // Set Z axis pin as an analog input
pinMode(13, OUTPUT); // Set timeout LED pin digital output
pinMode(9, OUTPUT); // set Relay pin as a digital output
Serial.begin(9600); // For serial debugging
delay(15000); // Give us time to leave the package
}
void loop() {
xval = analogRead(x); // Get X axis value
yval = analogRead(y); // Get Y axis value
zval = analogRead(z); // Get Z axis value
result1 = xval + yval + zval; // Add them all up
delay(100); // Wait 1/10 a second
xval = analogRead(x); // Get new X value
yval = analogRead(y); // Get new Y value
zval = analogRead(z); // Get new Z value
result2 = xval + yval + zval; // Add new values up
result_diff = abs(result2 - result1); // We only want + values
// This is debug code
Serial.print(" X_");
Serial.print(xval);
Serial.print(" Y_");
Serial.print(yval);
Serial.print(" Z_");
Serial.print(zval);
Serial.print(" R1_");
Serial.print(result1);
Serial.print(" R2_");
Serial.print(result2);
Serial.print(" Diff_");
Serial.print(result_diff);
Serial.print(" Thresh_");
Serial.println(threshold);
if (result_diff > threshold){ // Check to see if the difference is greater than the threshold, If it is, run code below.
digitalWrite(9,HIGH); // Turn on relay HONK!
delay(100); // Wait 1/10th a second
digitalWrite(9,LOW); // Turn off relay
digitalWrite(13,HIGH); // Turn on timeout LED
delay(5000); // Wait 5 seconds
digitalWrite(13,LOW); // Turn off timeout LED
}
else{
digitalWrite(9,LOW); // Keep relay off and do nothing
}
}
I have a question about the servo connector. The manual says this is for a button press on the transmitter. What signal is the camera expecting? Is it a 0 to 180 degree transition? or is it a simple on-off pulse?
Tried capturing serial images by using the arduino servo “sweep” example but I’m not getting consistent results. I assume I should get one picture per sweep, but I’m getting pictures at random times.
Product COM-11089 | last week
Reminds me of the ones you used to see on modems.
News - New Product Friday: Oh Fu… | about 2 weeks ago
Spade, this is the code I used. I’m not sure how to format it correctly for the comments so if you want me to email it to me, let me know.
I built one to “cure” the dog from getting into things I leave accessible by mistake when I leave the house. It’s going to make an appearance at work after the dog learns.
;) Chris
else{
Product KIT-10547 | about 3 weeks ago
http://www.youtube.com/watch?v=gcPdzsL0kMQ
Tutorial - Office Door Castle Knocker | about 3 weeks ago
Static electricity? Have you tried shielded wire?
News - Maker Faire San Mateo 201… | about 3 weeks ago
Hamvention rocks! Haven’t been to one in the last seven years, but when I lived in Ohio, I went to them every year.
I’m surprised SparkFun doesn’t at least have a small booth there. Most of the attendees are definitely the kind of people that would shop at SparkFun.
Now if someone would just modernize Hare Arena so it didn’t look like 1970 on the inside…
Product ROB-11162 | last month
Not bad for $30!
News - New Product Friday: Pull,… | last month
Someone woke up early today! I don’t usually see new pages posted until around 9:00 MST.
News - Final Soldering Competiti… | last month
And I, my Soldering Iron of Vengeance!
Product SEN-11171 | last month
I have a question about the servo connector. The manual says this is for a button press on the transmitter. What signal is the camera expecting? Is it a 0 to 180 degree transition? or is it a simple on-off pulse?
Tried capturing serial images by using the arduino servo “sweep” example but I’m not getting consistent results. I assume I should get one picture per sweep, but I’m getting pictures at random times.
What gives?
News - Education Website Launch | last month
Thank you!