@ Mark R
The following code is basic but should get you started
two buttons (momentary switches) pulled high, one when pressed will give you approx half speed and the other button will give approx full speed.
If both buttons pressed it will turn off and wait for button press again
tested in simulator so should help get you started, as others have stated the manual is the best place to start.
note: when driving dc (hobby) motors make sure to drive them via a transistor BD681 etc and add a 1N4007 and a 100n cap directly across the motor to avoid any noise upsetting the picaxe, 1k resistor between physical pin5 and the base of the transistor.
Regards
'Code
'*********************************************************
'* PWM OUT = PIN 2 (Physical pin 5) *
'* Half speed momentary switch = Pin 3 (Physical pin 4) *
'* Full speed momentary switch = Pin 1 (Physical pin 6) *
'* *
'*********************************************************
MAIN:
PAUSE 2000
IF PIN3=1 THEN Halfspeed
IF PIN1=1 THEN Fullspeed
GOTO MAIN
HALFSPEED:
pwmout 2 , 99, 200
if pin1 = 1 and pin3 = 1 then gosub MAIN
IF PIN1=1 THEN FULLSPEED
GOTO HALFSPEED
FULLSPEED:
pwmout 2 , 99, 400
if pin1 = 1 and pin3 = 1 then gosub MAIN
IF PIN3=1 THEN HALFSPEED
GOTO FULLSPEED