Hi I have ran a code that activates the Ultrasonic Sensor when the (ok) button is pressed. The problem is the code for the Ultrasonic sensor only runs when i press the ok button rather than looping. So i figured it would be beneficial to put the IR Input in the setup and have the ultrasonic sensor in the loop alone. How would i accomplish this?
I will happily pay someone via Paypal for an answer that works! Have been stuck on this for hours! Thankyou!
Here is the code below:
#include <IRremote.h>
const int receiver = 11;
const int led = 13;
const int echo = 10;
const int trig = 9;
What is the purpose of the IR control ?
Is it to activate the alarm, putting it in a "ready" state or suppress it (switch off the led) when triggered or what ?
6v6gt:
What is the purpose of the IR control ?
Is it to activate the alarm, putting it in a "ready" state or suppress it (switch off the led) when triggered or what ?
The purpose is to activate the Sensor putting it in a ready state. Then when the sensor is triggered by someone breaching the 30cm distance the LED should turn on.
Why don't you just leave the ultrasonic sensor running (that is, pinging away happily) all the time?
Then if there are times when you don't care if anyone is close or not, just don't use the reading? Just use the remote to cause it to check the distance and do the "intruder" thing.)
(I prefer to use the new ping library, much "tidier" code, and use blink-without-delay-thinking to time the pulses every 50ms or so.)
I've just restructured your code but not tested it. Your 'OK' IR button will activated it. Any other button will deactivate it.
I'm assuming the ultrasonic part worked before. Don't forget that the ultrasonic senso may need a stabilisation time.
6v6gt You are amazing! Please send me your paypal details or feel free to comment them back and i will happily transfer you $30 if thats enough! Look forward to your assistance on future projects too! Thankyou!