Shop OBEX P1 Docs P2 Docs Learn Events
Boe-Bot controlled by a NES gamepad — Parallax Forums

Boe-Bot controlled by a NES gamepad

BedwardsBedwards Posts: 4
edited 2011-06-06 13:18 in Robotics
I have a NES game-pad controller and adapter but don't know how to write the code to control the Boe-Bot.



Please Help, Bedwards

Comments

  • Oldbitcollector (Jeff)Oldbitcollector (Jeff) Posts: 8,091
    edited 2011-06-03 21:32
    Which part are you stuck on? Reading the NES game-pad or controlling the servos? or both?

    OBC
  • BedwardsBedwards Posts: 4
    edited 2011-06-04 12:30
    Yes, I have read the NES game-pad adapter instructions, but does not help me on figuring out how to control to servos using the NES game-pad.

    Bedwards
  • EricSEricS Posts: 1
    edited 2011-06-06 05:35
    Hi,

    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
  • BedwardsBedwards Posts: 4
    edited 2011-06-06 13:18
    Thanks so much.

    Bedwards
Sign In or Register to comment.