HOME

 
Basic Stamp 2
workshop
 

HARDWARE


SOFTWARE


EXAMPLES


EXTERNAL LINKS


 

Flashing LEDs with a potentiometer

Schema of the circuit

Code

'{$STAMP BS2}

'define a variable of size WORD
'
name it speed
'it will be the speed at which
'we flash the LED
speed VAR WORD

infiniteLoop: 'label

HIGH 1 'discharge the capacitor
PAUSE 1 'for 1 milisecond

'check the time it takes to charge
'and put the value in the variable speed
RCTIME 1,1,speed

'display the value of speed on screen
DEBUG ? speed

'now flash the LED
GOSUB Flash

GOTO infiniteLoop 'loop

Flash: 'subroutine labeled Flash

HIGH 0 'turn on LED
PAUSE speed 'wait x second
LOW 0 'turn off LED
PAUSE speed 'wait x second

RETURN 'go back to the rest of the program

 

top of page

vincent leclerc . v@uttermatter.com . 11-19-2003
sharerights extended to all
i am not responsible for any problems caused by suggestions made in this workshop