'code by Shaun Wilson April 17/99 'This program interfaces a MAX186 8 Channel ADC to the 'Basic Stamp II. The Stamp takes the 12 bit reading of the 'digital reparestion of the analog input into the ADC, 'and displays it on an LCD display. 'email - swilson@brunnet.net '--------------Variables---------------------------------------- Channel var nib 'set channel to 0 for if your using CH0 '1 if your using Ch1 and so on. Chsel var byte 'channel select ADCin var word 'ADC reading X var nib '----------------Constants------------------------------------- ClrLCD con 12 'Clear LCD N9600 con $4054 '9600 baud LCD con 0 'serial data to LCD display pin 0 cs con 1 'enable or disable A to D converter serDo con 2 'serial data out p2 serDin con 3 'serial data in p3 serclk con 4 'serial Clock p4 high cs 'disable pause 500 serout LCD,N9600,[ClrLCD] 'clear the screen serout LCD,N9600,["Ready",cr] main: low cs 'enable gosub chkADC gosub prnt goto main chkADC: channel =0 'set Channel = x, x being a nubmer between 0 to 7 depending on the channel you are using lookup channel, [142, 206,158,222,174,238,190,254],chsel 'tell Adc what channel shiftout serDo, serclk, msbfirst,[chsel] 'send the channel data shiftin serDin, serclk, msbpost ,[ADCin\12] 'the reading 'the reading high cs 'disable Return Prnt: serout LCD, N9600, ["Using Channel ", DEC channel,cr] serout LCD, N9600, [dec ADCin dig 3,".", dec ADCin dig 2, dec ADCin dig 1, dec ADCin dig 0 ,"Volts" ] 'print results pause 1000 serout LCD,N9600,[ClrLCD] 'clear screen Return
Text file Source (historic): geocities.com/siliconvalley/orchard/6633
geocities.com/siliconvalley/orchardgeocities.com/siliconvalley
(to report bad content: archivehelp @ gmail)
|
|
|
|
|