ADC code
This is what I'm using although this is for 3 led segments, I'm only using 2.
By changing the line :"for digitcounter = 1 to 3 'Convert reading to decimal"
1 to 2, I can get it working in a fashion !
Ta, Jeff
'Low resolution analog reading to 7 segment display 3 digits
'OPTIONS PICAXE-08
symbol dataout = 4
symbol clk = 0
symbol latchout = 2
symbol no = 0
symbol yes = 1
symbol decimalpoint = b1
symbol bitcounter = b2
symbol outbit = b3
symbol outbyte = b4
symbol areading = b5
symbol digitout = b6
symbol digitcounter = b7
decimalpoint = no 'Turn the decimal point off
loopa:
readadc 1, areading 'Read the analog value
for digitcounter = 1 to 3 'Convert reading to decimal
digitout = areading // 10
gosub outdigit
areading = areading / 10
next digitcounter
pulsout latchout, 1 'Display the reading
goto loopa
outdigit:
lookup digitout, ($BE, $82, $DC, $D6, $E2, $76, $7E, $92, $FE, $F2, $FA, $6E, $3C, $DE, $7C, $78), outbyte
if decimalpoint = no then nodec
outbyte = outbyte | $01 'Set bit 0
nodec:
for bitcounter = 0 to 7
outbit = outbyte & 1
if outbit = 1 then outhi
low dataout
goto clkout
outhi:
high dataout
clkout:
pulsout clk, 1
outbyte = outbyte / 2
next bitcounter
return