5.5 The Code
'**Variables**
symbol
keyPressed
= w0
symbol
motorSpeed
= w1
symbol
timeout
= w2
'**PICAXE motherboard pin definitions**
symbol
P6
= B.6
symbol
P13
= C.5
symbol
P14
= C.6
symbol
P15
= C.7
'**PICAXE motherboard input definitions**
symbol
IN14
= pinC.6
'**Pins**
symbol
LED_PIN
= P6
symbol
LeftMotor
= P13
symbol
RightMotor
= P15
symbol
IR_PIN
= P14
'**Inputs**
symbol IR_SIGNAL = IN14
'**IR Remote Keys**
symbol
KEY_UP
= 16
symbol
KEY_DOWN
= 17
symbol
KEY_LEFT
= 19
symbol
KEY_RIGHT
= 18
symbol
KEY_POWER
= 21
symbol
KEY_0
= 9
symbol
KEY_1
= 0
symbol
KEY_2
= 1
symbol
KEY_3
= 2
symbol
KEY_4
= 3
symbol
KEY_5
= 4
symbol
KEY_6
= 5
symbol
KEY_7
= 6
symbol
KEY_8
= 7
symbol
KEY_9
= 8
'**Initialise Motor Outputs**
High
LeftMotor
High
RightMotor
motorSpeed = 150
' Initial motor speed
pause
500
'**Main program Loop**
do
low
LED_Pin
' No IR command
Gosub
ReadIrCommand
' Read the IR command
High
LED_Pin
' Set LED when obeying command
Gosub
ObeyIrCommand
' Obey the IR command
loop
ReadIrCommand:
IrIn
IR_PIN, keyPressed
' Read an IR command
return
Содержание Versabot
Страница 1: ...The Versabot Manual July 2009...
Страница 23: ...Step 03 Step 04 Step 05...
Страница 24: ...Step 06 Step 07 Step 08...
Страница 25: ...Step 09 Step 10 Step 11...
Страница 26: ...Step 12 Step 13...