Atmega328P adc not working?

Thread Starter

Stevel28

Joined May 28, 2020
10
Really can't fathom why this code doesn't work. In effect whatever vale is input to adcin 0 (Port D7 = A0), the output PD7 remains 1.
In other words the port D7 doesn't appear to be sensitive to the input voltage. Am I leaving out something essential in the setup?

'Atmega328p. Potentiometer is connected to PC0
'which is ADC0
'Potentiometer on PC0 supposed to turn on LED (PD7) when 'turned to a value >= 120

Define CLOCK_FREQUENCY = 8
Dim pot As Byte
DDRD = 0xff
loop:
Adcin 0, pot
If pot < 120 Then
PD7 = 0
Else
PD7 = 1
Endif
Goto loop
End
 
Top