Page 160 - Robots Androids and Animatrons : 12 Incredible Projects You Can Build
P. 160
The program for PICBASIC compiler is as follows:
‘Neural Demo
‘Set up
low 0 ‘LED 0 off “Sleep”
low 1 ‘LED 1 off “Hunt”
low 2 ‘LED 2 off “Feed”
Start:
pot 3,255,b0 ‘Read first sensor
pot 4,255,b1 ‘Read second sensor
w2 = b0 * 3 ‘Apply weight
w3 = b1 * 2 ‘Apply weight
w4 = w2 + w3 ‘Sum results
‘Apply thresholds
if w4 < 40 then feed ‘Lots of light, feed
if w4 <= 300 then hunt ‘Medium light, hunt
if w4 > 300 then snooze ‘Little light, sleep
‘Actions
feed: ‘Feeding
low 0
low 1
high 2
139
goto start
hunt: ‘Hunting
low 0
high 1
low 2
goto start
snooze: ‘Sleeping * DON’T USE KEYWORD SLEEP *
high 0
low 1
low 2
goto start
Parts list for programming the microcontroller
PICBASIC compiler—$99.95
PICBASIC Pro compiler (includes CodeDesigner Lite)—$249.95
EPIC programmer—$59.95
PICBASIC Pro compiler and EPIC programmer—$299.95
PICBASIC compiler and EPIC programmer—$149.95
CodeDesigner—hobbyist version—$45.00
Team LRN Intelligence