Hello everyone,
I am new happy owner of a diablo but I am not programming in python.
I wonder if someone had written a code to control the board with a keaboard (exactly like diabloJoystick.py but with the arrow key).
Thanks.
# Setup the ZeroBorg
ZB = ZeroBorg.ZeroBorg()
#ZB.i2cAddress = 0x40 # Uncomment and change the value if you have changed the board address
ZB.Init()
if not ZB.foundChip:
boards = ZeroBorg.ScanForZeroBorg()
if len(boards) == 0:
print 'No ZeroBorg found, check you are attached :)'
else:
print 'No ZeroBorg at address %02X, but we did find boards:' % (ZB.i2cAddress)
for board in boards:
print ' %02X (%d)' % (board, board)
print 'If you need to change the I²C address change the setup line so it is correct, e.g.'
print 'ZB.i2cAddress = 0x%02X' % (boards[0])
sys.exit()
#ZB.SetEpoIgnore(True) # Uncomment to disable EPO latch, needed if you do not have a switch / jumper
ZB.SetCommsFailsafe(False)
ZB.ResetEpo()
with the Diablo setup lines:
# Setup the Diablo
DIABLO = Diablo.Diablo()
#DIABLO.i2cAddress = 0x44 # Uncomment and change the value if you have changed the board address
DIABLO.Init()
if not DIABLO.foundChip:
boards = Diablo.ScanForDiablo()
if len(boards) == 0:
print 'No Diablo found, check you are attached :)'
else:
print 'No Diablo at address %02X, but we did find boards:' % (DIABLO.i2cAddress)
for board in boards:
print ' %02X (%d)' % (board, board)
print 'If you need to change the I²C address change the setup line so it is correct, e.g.'
print 'DIABLO.i2cAddress = 0x%02X' % (boards[0])
sys.exit()
#DIABLO.SetEpoIgnore(True) # Uncomment to disable EPO latch, needed if you do not have a switch / jumper
DIABLO.ResetEpo()
Change the power settings lines:
# Power settings
voltageIn = 9.0 # Total battery voltage to the ZeroBorg (change to 9V if using a non-rechargeable battery)
voltageOut = 6.0 # Maximum motor voltage
to the correct values for your battery and motors in volts.
Mediaman25
Mon, 08/15/2016 - 19:13
Permalink
Keyboard control
Hello everyone,
I am new happy owner of a diablo but I am not programming in python.
I wonder if someone had written a code to control the board with a keaboard (exactly like diabloJoystick.py but with the arrow key).
Thanks.
piborg
Tue, 08/16/2016 - 11:30
Permalink
Diablo from Keyboard
I am not aware of a keyboard example for Diablo, but it should be easy to adapt 4ndr345's example for ZeroBorg: Easy script to control ZeroBorg with keyboard.
First swap the import line:
for the Diablo import:
Replace the setup lines:
with the Diablo setup lines:
Change the power settings lines:
to the correct values for your battery and motors in volts.
Change the move function:
to be:
Finally remove the line:
Mediaman25
Wed, 08/17/2016 - 12:55
Permalink
Thanks a lot for your reply.
Thanks a lot for your reply.
Here is the full script for the other who wants: