Example #1
0
import wificar
import time

wc = wificar.WifiCar()
wc.led('red')
time.sleep(1)
wc.led('blue')
time.sleep(1)
wc.led('green')
time.sleep(1)

for i in range(10):
    wc.inverse_led('green')
    time.sleep(1)

wc.led('red', False)
wc.led('green', False)
wc.led('blue', False)
#!/usr/bin/python
#-!- coding: utf-8 -!-

import time, wificar, sys, pygame, traceback

pygame.init()

if pygame.joystick.get_count() == 0:
    print "Could not find Joystick!"
    sys.exit()

joy = pygame.joystick.Joystick(0)
joy.init()

car = wificar.WifiCar()
car.reset()

print 'Car online ...'

try:
    while True:
        for event in pygame.event.get():  # just read the event.
            pass

        axes = [joy.get_axis(i) for i in range(joy.get_numaxes())]
        button = [joy.get_button(i) for i in range(joy.get_numbuttons())]
        hat = joy.get_hat(0)

        # if button 7 pressed, flash blue.
        if button[6]:
            car.led('blue', True)