ÿþ' Copyright Brad Campbell, 2007 - All rights reserved ' Nasty way of reading a Pot using junkbox parts on one port pin ' 1k 4.7kð ' pin %%½ð¾ð3%%½ð¾ð%»ð¼ð 10k ' 103­ð®ð ð ' Pretty basic. All junkbox parts ' Just continuously updates the ADC value. I get 255 as a minimum and 3109 as a maximum. ' It's not particularly linear, but it's close enough for my immediate needs. ' A bigger cap and more careful value selection would help. ' A bottle of Stones does not an electrical engineer make! ' Adjust reload to change the number of samples taken and change the "shr" to crop the ' innefective bits. ' Nothing new here.. shoulders of giants 'n all that. Got the idea years ago looking at some ' Scott Dattalo PIC code. VAR long conversion long pin PUB start(inval) : ok pin := inval OK := cognew(@ADC,@conversion) PUB getval : val val := conversion DAT ADC org mov da, par add da, #4 rdlong db, da mov da, #1 shl da, db mov inpin, da loop mov icnt, #0 mov da, reload andn dira, inpin cloop test inpin, ina wz IF_NZ jmp #high IF_Z jmp #low here djnz da, #cloop and da, inpin shr icnt, #2 wrlong icnt, par jmp #loop high nop andn outa, inpin or dira, inpin nop nop andn dira, inpin nop jmp #here low or outa, inpin or dira, inpin nop nop andn dira, inpin add icnt, #1 jmp #here zero long 0 allones long $FFFFFFFF reload long $4000 ' Number of samples icnt res 1 delay res 1 inpin res 1 da res 1 db res 1