Submitted by Webbot on January 1, 2009 - 10:55pm.

This class handles analogue to digital input pins.To create a new input pin using channel 4 (ADC4) just use:

A2D myIn(4);


You can then read an 8 bit value via:

unsigned char value = myIn.ReadByte();


or a 10 bit value via:

unsigned short value = myIn.ReadShort();


Notice that you DON'T need to initialise the A2D convertor at all. Look at the file you will see the Init method that, by default, is called with some default values. If you want to use other values then you can call this Init method yourself BEFORE you create any A2D inputs. Since this is a static method it can be done by writing:



If you need to save power and turn off the A2D function then call:


You can turn it back on later by calling A2D.Init again.