beautypg.com

Elenco Snap Circuits SnapMicro I Deluxe ® User Manual

Page 54

background image

53

readadc
Syntax:

READADC channel,variable

- channel is a variable or a constant that sets the input pin (1,2,or 4)

- variable is the name of the variable that holds the converted data.

Function:

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

Information:

The readadc command is used to read the analogue value from the micro-controller input pins 1, 2, or 4.

The readadc command converts this value to an 8-bit variable. An 8-bit resolution analogue input will

provide 256 different analogue readings (0 to 255) over the full voltage range (e.g. 0 to 4.5V). Note that

not all inputs have internal ADC capability. Use the readadc10 command to read the full 10-bit value.

Convert to Basic,

Program:

main:

readadc 1, b0

w1=b0*4

high 4

pause w1

low 4

pause w1

goto

main

Enter the flow chart shown here into the program editor then build the circuit

shown on the next page.

This manual is related to the following products: