Hey everyone,
I have an ambient light sensor that I'm inputting into the Arduino analogIn,
I need the input to be as clean as possible. Absolute 0 (little light) or absolute 1 (some light, or a lot of light)
If you visualize it, the input is an analog wave right now, and I want it to be digital. Can the Arduino do this? Is it already doing it and I don't know it? I'm assuming I need some code for what I want to do.
I've seen circuits that can be built, they use Operation Amplifiers with positive feedback to achieve "hysteresis"
If it is already built in the Arduino I could save some time.
If anyone has more info on this concept, or could point me towards educational information I would appreciate that too.
thanks for the help
-joe
Can the Arduino do this? Is it already doing it and I don't know it? I'm assuming I need some code for what I want to do.
I've seen circuits that can be built, they use Operation Amplifiers with positive feedback to achieve "hysteresis"
Yes, you can do this all within the software you create. In many ways it's better then using external hardware because you can easily make changes and 'tune' it later at no extra cost.
Basically you just need to have your sensor wired to a analog input pin (note, must be positive voltage only and not more then 5vdc). You then write code that creates a digital on/off variable 'flag' that you set or reset depending on the 'raw analog count' value you read from the analog input pin. Hysteresis is just making a small difference in the 'decision' count value for switching from on to off Vs off to on. Once you have the flag working, it's used to activate whatever outputs you wish. Your program runs in a continous loop, reading new analog input raw counts, updating the flag and changing outputs based on the flag setting.
That make sense?
Lefty
I think I understand the concept, is there any example code out there I could check out, to help wrap my head around it a little more?
thanks again
-joe
Have a look at the reference page for 'analogRead':
http://arduino.cc/en/Reference/AnalogRead