Okay, here’s what I’m trying to program in C.
I have an 8bit binary signal from an ADC on an ATmega32.
Now I want to convert that signal into an bar with 15LED’s that increases the higher the input value is.
So basically I want to cut my 8bit signal down to a 4bit one, convert it to decimal and show it at an increasing bar.
I first had the idea to check if my input is in a specific range (which would be always a range of 255/15) but I just couldn’t figure out how.
Just checking if the input is higher than a particular value won’t work because in that way there could be more than one condition at a time true.
Have you any idea how I could solve that? Any help is highly appreciated. 😉
Thank you!
Use this:
So only ADC value
0has all LEDs off, all other ADC values power on 1 to 16 LEDs. This has the advantage of not using any division (ATmega has no divisor instruction).EDIT: The above code actually assumes 16 LEDs, if you have 15 LEDs just do: