I have no clue how to code at all, the syntax has just never worked in my head lmfao anyhow I'm trying to make a Ping sensor light up LED's one by one as the person gets closer to this object, the issue for me is I want a button to turn this setting on in the first place, so if i had lets say an orb like object in the middle of my table cause i was some bullshit fortune teller, I would want to tap a button under the desk then 10 seconds later it's "on" and if a person gets closer to it.. it illuminates more? how is this done?
|
C
Arduino ping sensor turning on led, |
(Feb 15, 2016 07:06 PM)Coffee is love Wrote: I have no clue how to code at all, the syntax has just never worked in my head lmfao anyhow I'm trying to make a Ping sensor light up LED's one by one as the person gets closer to this object, the issue for me is I want a button to turn this setting on in the first place, so if i had lets say an orb like object in the middle of my table cause i was some bullshit fortune teller, I would want to tap a button under the desk then 10 seconds later it's "on" and if a person gets closer to it.. it illuminates more? how is this done? Hm. I have no idea how to do the code. But the basic concept can either be having the arduino wait to get a button press, then once it's pressed you turn on sensor and use a loop to keep checking. Or you use a loop and in each iteration check if the button is on, if it's on, you take the sensor data and affect the LED, else you just ignore the input. That's how I would think about it.
Feb 15, 2016 07:57 PM
(This post was last modified: Feb 15, 2016 08:20 PM by Motautronic.)
a switch and a infra red sensor should do the trick. or the ultrasonic audible sensor (hc-sr04). take your pick, actually have a look around and check youtube to find out which will suit best. i know there is a fair few guides out there and probably even some schematics and code for you too. i just remember there is and example for the ultrasonic audible sensor (hc-sr04) and i can tell you by just using that code and adding a few more lines of code you will get your result.
Feb 15, 2016 07:58 PM
(This post was last modified: Feb 15, 2016 07:59 PM by Coffee is love.)
Basically this is what it looks like without the button,
Code #define trigPin 7(Feb 15, 2016 07:58 PM)Coffee is love Wrote: Basically this is what it looks like without the button, I think you just need to wrap the if statements in the loop up in a bigger if statement that checks if button is in a "on" state or not. Should be trivial. |
|
|

