HOME - - - - - - - - - Other material for programmers - - - - - - - - - Pascalite, "How To Use It" main page

Pascalite hardware: Using the ADCs

Using the ADCs: Analog to Digital converters

The following assumes you've got your Pascalite set up and working. If it gives you what you want, great. Be advised, however, that this page is subordinate to others. Visit my Pascalite, "How To Use It" main page if you came drectly here and there are things "missing".

(You can show numbers on the LCD if you have one, but the following programs will also send at least part of every number to the four LEDs for those of you without an LCD display.)

The material supplied with the Pascalite is good, but just to be complete, here's a little program to illustrate the use of the analog to digital converter.

Be careful NOT to issue a def_out(d7) when you are using that pin to read ADC channel 3. Likewise, d4, d5, and d6 share pins with A0, A1 and A2 respectively, and can't be outputs and ADC inputs at the same time.

If you want to be fancy, take a potentiometer of between 5 Kand 100 K ohms. (About 15K would be best.) Attach one end to 5v, one end to GND, and connect the wiper to pin 3 and/or 4. If, from pervious exercises, you have a swtich and resistor on pins 3 and 4, you can kludge as follows: "short" out the (open) switch with resistors of various values. You should see different numbers in bADC.

If you then enter and run the following, you should see a changing number output as you change the position of the wiper on the potentiometer.

program IntTutADC;
var bADC,bTmpG:byte;

procedure NumToLCD(bDisp:byte);
(As IntTut4)
end; {of procedure}

write(LCD,255); {clears LCD}
bTmpG:=bADC MOD 10;
write(portd,bTmpG);{This line for people without LCD displays}
until 4=5;

To search THIS site.... (Go to the site's above, and use their search buttons if you want to seach them.)... Way to search this site without using forms
Search this site or the web powered by FreeFind

Site search Web search

Ad from page's editor: Yes.. I do enjoy compiling these things for you... hope they are helpful. However.. this doesn't pay my bills!!! If you find this stuff useful, (and you run an MS-DOS or Windows pc) please visit my freeware and shareware page, download something, and circulate it for me? Links on your page to this page would also be appreciated!
Click here to visit editor's freeware, shareware page.

Link to editor's (Arunet) homepage
How to email or write this page's editor, Tom Boyd