Oct. 04........Analog-to-Digital Conversion (ADC) Input
Assignment Journal 04
Based on my last project, Now I want the LEDs to light up according to the potentiometer. When they're getting lower voltage, only few of them light up and as the voltage adds up, more LEDs light up. When I reach the highest range, LEDs light up in turns just like "wave dance"?? we're doing when watching a baseball game or whatever.
This is not a big project so I just tried to make sure I could measure the voltage I'm getting and started working on it. I didn't use a photocell because the voltage seems varies a lot according to the environment and I'm afraid it won't work in other place.
Make sure I know the range of the voltage and started to build them into 7 different groups. (Because I have 6 LEDs)
Put the sequence of LEDs into an array. (Because I thought they were not in accending mode...Later I found out they're just 10-15 in sequence. But I got to know how to work with the array anyway.)
The difficult part is the last group. I make the LEDs light up in turns repeatedly, so there is a "Loop" inside the subprogram. However, if so, I can't get them back to the mode when only certain ones light up. The program is trapped within the Loop inside this subprogram.
Here's what I did, put an "if" in it and start with the situation in which you don't have them to go loop. So whenever the program runs, it'll check the situation. As soon as it finds out it doesn't match. it quits immediately.
Another part I neglected was I didn't check the voltage within the subprogram. So though I change the voltage, it was still getting the value that activated the program. Therefore I have to detect the voltage in the sugprogram again in a Loop mode and then the LEDs know when to quit.
Graphic and code and chart....see the chartsee the code
LEDs light up according to the voltage the chip gets.(it's hard to tell I know. I won't use a flashlight next time.)