Exemplo n.º 1
0
def pi2goInit():
    print "pi2go Init"
    global piStop
    global speed

    piStop = True
    
    if piExists:
        pi2go.init()
        vsn = pi2go.version()
        if vsn == 1:
            print "Running on Pi2Go"
        else:
            print "Running on Pi2Go-Lite"

        speed = 50

        #pi2go.forward(speed)
    else:  # function place holder in case the program is not running on pi2go
        demo()
Exemplo n.º 2
0
import pi2go, time

pi2go.init()

vsn = pi2go.version()
try:
  if vsn != 1:
    print "This program only runs on the full Pi2Go"
  else:
    while True:
        pi2go.setAllLEDs(0, 0, 0) # start with all OFF
        for i in range(4):
            pi2go.setLED(i, 4095, 0, 0) # set to Red
            print 'Red'
            time.sleep(0.2)
            pi2go.setLED(i, 0, 0, 0)
        for i in range(4):
            pi2go.setLED(i, 0, 4095, 0) # set to Green
            print 'Green'
            time.sleep(0.2)
            pi2go.setLED(i, 0, 0, 0)
        for i in range(4):
            pi2go.setLED(i, 0, 0, 4095) # set to Blue
            print 'Blue'
            time.sleep(0.2)
            pi2go.setLED(i, 0, 0, 0)
        for i in range(4):
            pi2go.setLED(i, 4095, 4095, 4095) # set to White
            print 'White'
            time.sleep(0.2)
            pi2go.setLED(i, 0, 0, 0)
#
# Created by Gareth Davies, May 2014
# Copyright 4tronix
#
# This code is in the public domain and may be freely copied and used
# No warranty is provided or implied
#
#======================================================================

import pi2go, time
LEDon = 4095
LEDoff = 0

pi2go.init()

vsn = pi2go.version()

if vsn != 1:
    print "This program only runs on the full Pi2Go"
else:
    pi2go.setAllLEDs(LEDoff, LEDoff, LEDoff)

pi2go.setAllLEDs(LEDon, LEDoff, LEDoff)
print "Red"
time.sleep(1)
pi2go.setAllLEDs(LEDoff, LEDon, LEDoff)
print "Green"
time.sleep(1)
pi2go.setAllLEDs(LEDoff, LEDoff, LEDon)
print "Blue"
time.sleep(1)
Exemplo n.º 4
0
#!/usr/bin/python
# servoTest.py

import pi2go

# Define pins for Pan/Tilt
pan = 0
tilt = 1
tVal = 0 # 0 degrees is centre
pVal = 0 # 0 degrees is centre

pi2go.init()
print "Pi2Go version: ", pi2go.version()

def doServos():
    pi2go.setServo(pan, pVal)
    pi2go.setServo(tilt, tVal)

try:
    while True:
        key=raw_input("Move Pan/Tilt Servos W-Up, Z-Down, A-Left, S-Right Space=Centre, X=Stop:")
        if key==" ":
            tVal = 0
            pVal = 0
            doServos()
            print "Centre"

        if key=="x":
            pi2go.stopServos()
            print "Stop"
Exemplo n.º 5
0
    getchar = getchar_fn or readchar
    c1 = getchar()
    if ord(c1) != 0x1b:
        return c1
    c2 = getchar()
    if ord(c2) != 0x5b:
        return c1
    c3 = getchar()
    return chr(0x10 + ord(c3) - 65)  # 16=Up, 17=Down, 18=Right, 19=Left arrows


# End of single character reading
#======================================================================

pi2go.init()
if pi2go.version() == 1:
    print "Pi2Go Version: FULL"
else:
    print "Pi2Go Version: LITE"


def doServos():
    pi2go.setServo(pan, pVal)
    pi2go.setServo(tilt, tVal)


print "Use Arrows or W-Up, Z-Down, A-Left, S-Right Space=Centre, ^C=Exit:"

try:
    while True:
        key = readkey()
Exemplo n.º 6
0
    getchar = getchar_fn or readchar
    c1 = getchar()
    if ord(c1) != 0x1b:
        return c1
    c2 = getchar()
    if ord(c2) != 0x5b:
        return c1
    c3 = getchar()
    return chr(0x10 + ord(c3) - 65)  # 16=Up, 17=Down, 18=Right, 19=Left arrows

# End of single character reading
#======================================================================


pi2go.init()
if pi2go.version() == 1:
    print "Pi2Go Version: FULL"
else:
    print "Pi2Go Version: LITE"

def doServos():
    pi2go.setServo(pan, pVal)
    pi2go.setServo(tilt, tVal)

print "Use Arrows or W-Up, Z-Down, A-Left, S-Right Space=Centre, ^C=Exit:"

try:
    while True:
        key = readkey()
        if key == ' ':
            tVal = 0
Exemplo n.º 7
0
    getchar = getchar_fn or readchar
    c1 = getchar()
    if ord(c1) != 0x1b:
        return c1
    c2 = getchar()
    if ord(c2) != 0x5b:
        return c1
    c3 = getchar()
    return chr(0x10 + ord(c3) - 65)  # 16=Up, 17=Down, 18=Right, 19=Left arrows

# End of single character reading
#======================================================================


pi2go.init()
print "pi2go version: ", pi2go.version()

def doServos():
    pi2go.setServo(pan, pVal)
    pi2go.setServo(tilt, tVal)

print "Use Arrows or W-Up, Z-Down, A-Left, S-Right Space=Centre, ^C=Exit:"

try:
    while True:
        key = readkey()
        if key == ' ':
            tVal = 0
            pVal = 0
            doServos()
            print "Centre"