I want to program a ATmega 32A to turn on 3 DIP white color led and I want to turn on…
- User
I want to program a ATmega 32A to turn on 3 DIP white color led and I want to turn on this led’s based on value of a 10K potentiometer ( this will act as a bar graph to indicate the value led one turn on in 100 ohm, LED2 turn on in 341 ohm and LED3 in 680 ohm) what the code to compile on atmega32 and how install this
- Assistant
- User
I want to program a ATmega 32A to turn on 3 DIP white color led and I want to turn on this led’s based on value of a 10K potentiometer ( this will act as a bar graph ) After rotating the potentiometer, the first LED should turn on after the value of 100 ohms, then the second LED should turn on after the value of 341 ohms, and finally the third LED should turn on after the value of 680 ohms. It should be noted that the purpose of this work is to make a bar graph and it wants to divide the produced light intensity into three categories: low, medium and high.
- Assistant
- User
in the code above it doesn't work for LED 3( it's not turn on) and also the gap between led 1 and 2 is very little
- Assistant
- User
in this line compiler give me this errors :
- Assistant
If you encounter a compiler error with the line:
c - User
in this lines, compiler give me this errors : main.c:28:26: warning: integer overflow in expression [-Woverflow] if (adcValue >= (100 * 1023 / 10000)) { ^ main.c:31:26: warning: integer overflow in expression [-Woverflow] if (adcValue >= (341 * 1023 / 10000)) { ^ main.c:34:26: warning: integer overflow in expression [-Woverflow] if (adcValue >= (680 * 1023 / 10000)) {
please change the code
- Assistant
The warnings you're receiving are due to the division and multiplication of literals that are being interpreted as
inttypes, which could potentially overflow theinttype. These calculations should be rewritten so that division happens after multiplication, and we can make the result a floating-point calculation by being explicit about decimal places or casting one of the operands to float or double before the operation.