I recently set up my boe bot to run off of an NES controller so I thought I would share a few code snippets which might help. I am fairly new to this so it may not be the best way but it works for me and it's actually quite fun. This example exits the loop when you hit start so you may want to add some code after the loop or change how that works.
You may have to modify the code depending which pins you use. I used the same servo pins as used in the boe bot demo and the same NES pins used in the NES controller manual.
NES_START CON 8
NES_SELECT CON 4
NES_B CON 2
NES_A CON 1
NES_UP CON 16
NES_DOWN CON 32
NES_LEFT CON 64
NES_RIGHT CON 128
value VAR byte
DirectControl:
GOSUB getNESData
DO UNTIL value & nes_start = 0
GOSUB GetNESData
IF value > 0 THEN
IF (value XOR 255) = nes_left THEN
PULSOUT 13,700
PULSOUT 12,700
ELSEIF (value XOR 255) = nes_right THEN
PULSOUT 13,800
PULSOUT 12,800
ELSEIF (value XOR 255) = nes_up THEN
PULSOUT 13,800
PULSOUT 12,700
ELSEIF (value XOR 255) = nes_down THEN
PULSOUT 13,700
PULSOUT 12,800
ELSEIF (value XOR 255) = (nes_up | nes_left) THEN
PULSOUT 12,700
ELSEIF (value XOR 255) = (nes_up | nes_right) THEN
PULSOUT 13,800
ELSEIF (value XOR 255) = (nes_down | nes_right) THEN
PULSOUT 12,800
ELSEIF (value XOR 255) = (nes_down | nes_left) THEN
PULSOUT 13,700
ENDIF
ENDIF
LOOP
GetNESData:
PULSOUT 5, 10 ' Latch the data
SHIFTIN 6,4,LSBPRE, [value \8] ' Shift in socket 1 data
RETURN
Comments
OBC
Bedwards
I recently set up my boe bot to run off of an NES controller so I thought I would share a few code snippets which might help. I am fairly new to this so it may not be the best way but it works for me and it's actually quite fun. This example exits the loop when you hit start so you may want to add some code after the loop or change how that works.
You may have to modify the code depending which pins you use. I used the same servo pins as used in the boe bot demo and the same NES pins used in the NES controller manual.
Bedwards