Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
program ADC_Test
main:
DDRB = $FF
DDRD = $FF
DDRC = 0
ADMUX = 0
DIDR0 = $3F
ADCSRA = $85
while true
ADCSRA.ADCS = 1
while (ADCSRA.ADCS)
wend
PORTB = ADCL
PORTD = ADCH
delay_ms(2)
wend
end.
program ADC_LCD
symbol RW = PORTB.B1
symbol RW_Direction = DDRB.B1
dim LCD_RS as sbit at PORTB2_bit
dim LCD_EN as sbit at PORTB3_bit
dim LCD_D4 as sbit at PORTB4_bit
dim LCD_D5 as sbit at PORTB5_bit
dim LCD_D6 as sbit at PORTB6_bit
dim LCD_D7 as sbit at PORTB7_bit
dim LCD_RS_Direction as sbit at DDB2_bit
dim LCD_EN_Direction as sbit at DDB3_bit
dim LCD_D4_Direction as sbit at DDB4_bit
dim LCD_D5_Direction as sbit at DDB5_bit
dim LCD_D6_Direction as sbit at DDB6_bit
dim LCD_D7_Direction as sbit at DDB7_bit
dim Value as longword
dim Disp as word[3]
dim sValue as string[5]
dim sDisp as string[5]
main:
RW_Direction = 1
RW = 0
LCD_Init()
LCD_Cmd(_LCD_CLEAR)
LCD_Cmd(_LCD_CURSOR_OFF)
LCD_Out(1, 1, "Reading:")
LCD_Out(2, 1, "Voltage:")
sDisp = "4.99V"
while true
Value = ADC_Read(0)
WordToStr(Value, sValue)
LCD_Out(1, 10, sValue)
Value = (Value * 500) >> 10
Disp[0] = (Value div 100) + 48
Disp[1] = ((Value div 10) mod 10) + 48
Disp[2] = (Value mod 10) + 48
sDisp[0] = Disp[0]
sDisp[2] = Disp[1]
sDisp[3] = Disp[2]
LCD_Out(2, 10, sDisp)
wend
end.
program ADC_int
dim done as byte
sub procedure ADC_Int() org $015
PORTB = ADCH
end sub
sub procedure TMR0_Int() org $010
ADCSRA.ADSC = 1 'ADCSRA.ADSC 'START CONVERSION
end sub
main:
DDRB = $FF 'ALL OUTPUT
DDRC = 0 'ALL INPUT
TCCR0A = 0 'NORMAL OPERATION
TCCR0B = 3 'PRESCALER 64
SREG = $80 'GIE
TIMSK0 = 1 'ENABLE TMR0 INTERRUPT
ADMUX = $20 '8-bit, CH0
DIDR0 = $3F 'ALL ANALOG
ADCSRA = $8D 'ADC ON, INTERRUPT ENABLED, FOSC/64
while true
wend
end.