Show Posts
|
|
Pages: [1] 2 3 ... 158
|
|
3
|
Using Arduino / Programming Questions / Re: Checking Rapid Blinking Input
|
on: May 22, 2013, 12:56:27 pm
|
|
Keep an array of unsigned longs. Loop through your pins and digitalRead them. For any that are high, store millis in the corresponding array entry. Loop through the array and compare the times to millis. If any of them have a difference > 750mS, shut everything down.
This assumes that you can wait a little. A similar, but slightly more complex approach will be needed if you want to catch the "I'm going to shut down shortly" signal.
|
|
|
|
|
4
|
Using Arduino / Project Guidance / Re: Mearing flow rate
|
on: May 22, 2013, 07:03:11 am
|
|
The PulseIn function will get you the PWM detail. You can write the data to a file on an SD card if you have the hardware, or send it to a PC running a program that will push it to a file. Processing is often used for this purpose although you can write the receiving program in your language of choice or use a terminal program that can capture input to file.
|
|
|
|
|
7
|
Using Arduino / Project Guidance / Re: Servo minimum delay?
|
on: May 21, 2013, 01:01:55 pm
|
|
Without actually looking at the servo library, I'm going to guess that it makes no difference how fast you're setting the servos to position. The library has to send the signal frequently (every 20mS?) so I suspect that your new data will be used the next time it's time to send, unless you overwrite it before that.
|
|
|
|
|
9
|
Using Arduino / Programming Questions / Re: trying to parse a serial string with strange results
|
on: May 17, 2013, 04:07:55 pm
|
|
Your code contains a tacit assumption that the string you typed will all be read back to back in your while loop. It won't - the arduino is much too fast for that. It'll read a single char, check for another being available and nothing will have arrived.
Get rid of the i=0; at the top of loop. You'll need it somewhere, but not there.
|
|
|
|
|
12
|
Community / Gigs and Collaborations / Re: Help with project - financial reward!
|
on: May 17, 2013, 10:26:23 am
|
|
It uses a static boolean local variable (a global would work too) to keep track of whether the camera is recording or not.
Every time loop executes, it checks to see if either of the pirs are detecting anything. If one or both of them is detecting, it checks to see whether the camera is already recording. If it is, the code does nothing, if it isn't, it sends the REC command to start recording.
If neither pir sees anything, it checks to see whether the camera is recording. If it is, send REC to turn it off; if it's not, do nothing.
|
|
|
|
|
13
|
Community / Gigs and Collaborations / Re: Help with project - financial reward!
|
on: May 17, 2013, 08:52:11 am
|
Here's the logic in loop that I think will do what you want. I don't see anything in your code that commands the camera, but you say you've managed to get it into record mode so I've assumed a function that does it. void loop() { static bool Recording=false; // Is the camera recording? ldr_value = analogRead(ldrpin); //read LDR value if (ldr_value >300) { nightservo.write(27); // IE dark , tell servo to go to position 27 } else { nightservo.write(5); } pirvalue1 = digitalRead(pir1); //read pirvalue pirvalue2 = digitalRead(pir2); if(pirvalue1==HIGH || pirvalue2==HIGH) { if(!Recording) { Recording=true; SendRecCommand(); // Start recording } } else { if(Recording) { Recording=false; SendRecCommand(); // Stop recording } } }
|
|
|
|
|