Example #1
0
import FNG_motordriver as FNG
import ultrasonic_lib as ultrasonic
import curses
import time
import sys

stdscr = curses.initscr()
curses.noecho()
curses.cbreak()
robot = FNG.robot()
sensor = ultrasonic.sensor()

robot.stop()

while True:
    try:
        cmd = stdscr.getch
        distance = sensor.get_range()

        if cmd == ord('w'):
            robot.forward()

        elif cmd == ord('s'):
            robot.backward()

        elif cmd == ord('d'):
            robot.left_turn()

        elif cmd == ord('a'):
            robot.right_turn()
Example #2
0
#!/usr/bin/python
import cwiid
import time, sys
import FNG_motordriver as FNG

robot = FNG.robot(18, 23, 24, 25, 12) #stby, dir1, dir2, DIR1, DIR2

button_delay = 0.1

print 'press the button on wiimote'

time.sleep(1)

try:
  wii = cwiid.Wiimote()

except RuntimeError:
  print "Error opening wiimote connection"
  sys.exit()

print 'connected! ctrl + c to exit'

wii.rpt_mode = cwiid.RPT_BTN

while True:
    try:
        buttons = wii.state['buttons']

        if (buttons & cwiid.BTN_LEFT):
            robot.left_turn()