Name:
readadc
Syntax:

READADC channel,variable

Channel - is a variable/constant specifying the ADC channel (not pin number)

Variable - receives the data byte read.

Description:

Read the ADC channel (8 bit resolution) contents into variable.

The readadc command is used to read the analogue value from the microcontroller input pins. Note that not all inputs have internal ADC functionality - check the pinout diagrams for the PICAXE chip you are using. On X2 parts you must use the ADC channel, not the pin number, in the readadc command (e.g. readadc 0,w1 NOT readadc A.0, w1).  The readadc10 command can be used for higher resolution.

Applies To:
All
See Also:
Related Create:
Share:
Print:

Read an analogue voltage

Read an analogue voltage on analogue channel 0 and flash a LED on output B.1 when higher than a value of 50

Code Example:
main:	readadc 0,b1		; read value into b1
	if b1 > 50 then flsh	; jump to flsh if b1 > 50
	goto main		; else loop back to start

flsh:	high B.1		; switch on output B.1
	pause 1000		; wait 1 second
	low B.1			; switch off output B.1
	pause 1000		; wait 1 second
	goto main		; loop back to start
Copy Code Submit an Example

Submit Your Own Code!

You must be logged in to submit code examples. Login now.