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.
Select ADC.read(0)
Case <50
'no button pressed
Case <150 ' ideal=92
'button 1 pressed
Case <250 ' ideal=185
'button 2 pressed
Case <350 'ideal=278
'button 3 pressed
Case <450 'ideal=371
'button 4 pressed
Case <550 'ideal=464
'button 5 pressed
Case <650 'ideal=557
'button 6 pressed
Case <750 'ideal=650
'button 7 pressed
Case <850 'ideal=743
'button 8 pressed
Case <950 'ideal=836
'button 9 pressed
Case <1050 'ideal=929
'button 10 pressed
else
'something is wrong
End Select
Device = 18f2420
Clock = 8
Include "InternalOscillator.bas"
Include "SetDigitalIO.bas"
Include "adc.bas"
Include "Utils.bas"
Include "SUART.bas"
Include "convert.bas"
SetTX(PORTC.6)
SetRX(PORTC.7)
SetBaudrate(sbr19200)
SetMode(umTrue)
ADCON1 = $07
CMCON = $07
TRISA.0 = 1 // configure AN0 as an input
ADCON1.7 = 1 // set analogue input on PORTA.0
While true
Select ADC.Read(0)
Case <50
UART.Write("No button",13,10)'no button pressed
DelayMS (200)
Case <150 ' ideal=92
UART.Write("button1",13,10) 'button 1 pressed
DelayMS (200)
Case <250 ' ideal=185
UART.Write("button2",13,10) 'button 2 pressed
DelayMS (200)
Case <350 'ideal=278
UART.Write("button3",13,10) 'button 3 pressed
DelayMS (200)
Case <450 'ideal=371
UART.Write("button4",13,10) 'button 4 pressed
DelayMS (200)
Case <550 'ideal=464
UART.Write("button5",13,10)'button 5 pressed
DelayMS (200)
Case <650 'ideal=557
UART.Write("button6",13,10) 'button 6 pressed
DelayMS (200)
Case <750 'ideal=650
UART.Write("button7",13,10) 'button 7 pressed
DelayMS (200)
Case <850 'ideal=743
UART.Write("button8",13,10) 'button 8 pressed
DelayMS (200)
Case <950 'ideal=836
UART.Write("button9",13,10) 'button 9 pressed
DelayMS (200)
Case <1050 'ideal=929
UART.Write("button10",13,10) 'button 10 pressed
DelayMS (200)
Else
'something is wrong
End Select
Wend
Device = 18f2420
Clock = 8
Include "InternalOscillator.bas"
Include "SetDigitalIO.bas"
Include "adc.bas"
Include "Utils.bas"
Include "SUART.bas"
Include "convert.bas"
DIM value AS WORD
SetTX(PORTC.6)
SetRX(PORTC.7)
SetBaudrate(sbr19200)
SetMode(umTrue)
ADCON1 = $07
CMCON = $07
TRISA.0 = 1 // configure AN0 as an input
ADCON1.7 = 1 // set analogue input on PORTA.0
While true
value = ADC.Read(0)
UART.Write(value,13,10)
DelayMS (200)
wend
It can't send what ever you want.but the uart shows what button instead
10 damn pages of simulations and example code showing equal 1K resistors and you continue to use whatever you feel like.has 2K resistor to grd. but will try without the extra 2K resistor