I'm trying to develop software using the Easy AVR 6 board to do this:
Code: Select all
do {
for(cnt=0; cnt<=1; cnt++)
{
if(cnt == 0)
{
adc = 0;
adc = ADC_read(cnt); // Read ADC value pin PA0 Atmega 32
if (adc>=0 && adc<250)
{
PORTC0_bit = ~PORTC0_bit; // ON-OFF output pin C0 Atmega 32
}
else
if (adc>=251 && adc<500)
{
PORTC1_bit = ~PORTC1_bit; // ON-OFF output pin C1 Atmega 32
}
else
{
PORTC2_bit = ~PORTC2_bit; // ON-OFF output pin C2 Atmega 32
}
}
if(cnt == 1) {
adc = 0;
adc = ADC_read(cnt); // Read ADC value pin PA1 Atmega 32
//.....
}
}
Delay_ms(100);
} while(1);
The problem is that I have to press the same switch several times so that the corresponding output (PC0, PC1, PC2) to switch from 0V to 5V OR 5V to 0V !!! I believe that the pressing, which normally does not take more than a second, is scanned by the software several times and in the end the MCU decides to let the corresponding output from 0V to 5V or 5V to 0V. So I have to press the same switch several times in a row to get, at some point, say, a 5V on the PC0 output and I would not want that! I mean, I don't want to press the same switch several times.
Yours have any ideas / tips that I could add in the software so that I don't press the same switch several times? Please!