Posted: 05:26pm 03 May 2013 |
Copy link to clipboard |
Print this post |
|
Hi Graeme,
The following code may give you some ideas - I tested on a Duinomite Mega running 4.3A
Cheers,
Doug.
' Program to demonstrate use of analogue input pin
' to increase a variable while a switch is
' closed and return to normal rate on release
' Use pin 1 as analogue input with pullup resistor
' to hold high and normally open switch to ground.
' Pin will be high until switch operated.
Entry:
slow = 10 ' initial "slow" value for rate
rate = slow ' set rate to initial value
SetPin 1,1 ' setup pin to be used as analogue input
' Now for the interrupt handler to check if key pressed
SetTick 500,switch_check 'interrupt every 500mS
Main:
' main program area - I just print rate to demo
Print rate,;
Pause 50
GoTo main
'Interrupt service routine
switch_check:
If Pin(1) = 0 Then
rate = rate + 1
Else
rate = slow
EndIf
IReturn
... almost all of the Maximites, the MicromMites, the MM Extremes, the ArmMites, the PicoMite and loving it! |