コード例 #1
0
ファイル: zeropoint.py プロジェクト: RyanteckLTD/RTk
def init(delay = 0.0015):
  global running, StepCount, StepDir, stepsToDo, StepPosition, StepPins
  global StepCounter, Seq, WaitTime
  # Use physical pin numbers
  GPIO.setmode(GPIO.BCM)
 
  # Define GPIO signals to use
#  StepPins = [35,36,32,33]   # RoboHat
  StepPins = [4, 17, 27, 18]  # ZeroPoint
 
  # Set all pins as output
  for pin in StepPins:
    GPIO.setup(pin,GPIO.OUT)
    GPIO.output(pin, False)

  # Define pin sequence
  Seq = [[1,0,0,1],
       [1,0,1,0],
       [0,1,1,0],
       [0,1,0,1]]
       
  StepCount = len(Seq)
  StepDir = 1 # 1 == clockwise, -1 = anticlockwise
  StepsToDo = 0 #number of steps to move
  StepPosition = 0 # current steps anti-clockwise from the zero position

  # Initialise variables
  StepCounter = 0
  WaitTime = delay
  running = True
  # Move pointer to zero position
  StepDir = -1
  stepsToDo = 700
  step()
コード例 #2
0
def init(delay=0.0015):
    global running, StepCount, StepDir, stepsToDo, StepPosition, StepPins
    global StepCounter, Seq, WaitTime
    # Use physical pin numbers
    GPIO.setmode(GPIO.BCM)

    # Define GPIO signals to use
    #  StepPins = [35,36,32,33]   # RoboHat
    StepPins = [4, 17, 27, 18]  # ZeroPoint

    # Set all pins as output
    for pin in StepPins:
        GPIO.setup(pin, GPIO.OUT)
        GPIO.output(pin, False)

    # Define pin sequence
    Seq = [[1, 0, 0, 1], [1, 0, 1, 0], [0, 1, 1, 0], [0, 1, 0, 1]]

    StepCount = len(Seq)
    StepDir = 1  # 1 == clockwise, -1 = anticlockwise
    StepsToDo = 0  #number of steps to move
    StepPosition = 0  # current steps anti-clockwise from the zero position

    # Initialise variables
    StepCounter = 0
    WaitTime = delay
    running = True
    # Move pointer to zero position
    StepDir = -1
    stepsToDo = 700
    step()
コード例 #3
0
def setup():
    GPIO.setmode(GPIO.BCM)
    for l in LED_GPIO:
        GPIO.setup(l, GPIO.OUT)
        GPIO.output(l, False)

    for b in BUTTON_GPIO:
        GPIO.setup(b, GPIO.IN)
コード例 #4
0
ファイル: testHardware.py プロジェクト: RyanteckLTD/RTk
def setup():
  GPIO.setmode(GPIO.BCM)
  for l in LED_GPIO:
    GPIO.setup(l, GPIO.OUT)
    GPIO.output(l, False)

  for b in BUTTON_GPIO:
    GPIO.setup(b, GPIO.IN)
コード例 #5
0
ファイル: lcd_16x2.py プロジェクト: tadryanom/RyanteckLTD_RTk
def main():
  # Main program block
  
  #GPIO.setwarnings(False)
  GPIO.setmode(GPIO.BCM)       # Use BCM GPIO numbers
  GPIO.setup(LCD_E, GPIO.OUT)  # E
  GPIO.setup(LCD_RS, GPIO.OUT) # RS
  GPIO.setup(LCD_D4, GPIO.OUT) # DB4
  GPIO.setup(LCD_D5, GPIO.OUT) # DB5
  GPIO.setup(LCD_D6, GPIO.OUT) # DB6
  GPIO.setup(LCD_D7, GPIO.OUT) # DB7


  # Initialise display
  lcd_init()

  while True:

    # Send some test
    lcd_string("RTk.GPIO",LCD_LINE_1)
    lcd_string("16x2 LCD Test",LCD_LINE_2)

    time.sleep(3) # 3 second delay

    # Send some text
    lcd_string("1234567890123456",LCD_LINE_1)
    lcd_string("abcdefghijklmnop",LCD_LINE_2)



    time.sleep(3) # 3 second delay

    # Send some text
    lcd_string("Code by",LCD_LINE_1)
    lcd_string("RPiSPY",LCD_LINE_2)

    time.sleep(3)

    # Send some text
    lcd_string("Wow, Very LCD",LCD_LINE_1)
    lcd_string("Such Magic",LCD_LINE_2)

    time.sleep(3)

   lcd_string("All done on a", LCD_LINE_1)
   lcd_string("Desktop Computer", LCD_LINE_2)
   time.sleep(3)
コード例 #6
0
import mcpi.minecraft as minecraft
import mcpi.block as block
import mcpi.minecraftstuff as minecraftstuff
import time
import random
import thread
import anyio.seg7 as display
import anyio.GPIO as GPIO

BUTTON = 4
LED_PINS = [7,6,14,16,10,8,9,15]

GPIO.setmode(GPIO.BCM)
GPIO.setup(BUTTON, GPIO.IN)
ON = False # common-anode, set to True for common cathode
display.setup(GPIO, LED_PINS, ON)

#arena constants
ARENAX = 20
ARENAZ = 30
ARENAY = 5
RIVERWIDTH = 6

def createArena(pos):
    mc = minecraft.Minecraft.create()
    pos.x
    mc.setBlocks(pos.x - 1, pos.y, pos.z - 1,
                 pos.x + ARENAX + 1, pos.y - 3,
                 pos.z + ARENAZ + 1, block.GRASS.id)
    mc.setBlocks(pos.x - 1, pos.y + 1, pos.z - 1,
                 pos.x + ARENAX + 1, pos.y + ARENAY, pos.z + ARENAZ + 1,
コード例 #7
0
# BIG BANG - COUNTDOWN

# Import modules
import mcpi.minecraft as minecraft
import mcpi.block as block
import time
#import RPi.GPIO as GPIO
import anyio.GPIO as GPIO

# GPIO pins on breadboard
BANG = 15

# Setup
mc = minecraft.Minecraft.create()
GPIO.setmode(GPIO.BCM)  # use broadcom GPIO numbers
GPIO.setup(BANG, GPIO.OUT)

pos = mc.player.getTilePos()
mc.setBlock(pos.x + 1, pos.y, pos.z, block.GOLD_BLOCK.id)
mc.postToChat("hit that gold block!")

# Main loop
while True:
    time.sleep(0.1)

    # Input Sensing
    bang = False
    events = mc.events.pollBlockHits()
    for e in events:
        pos = e.pos
        b = mc.getBlock(pos.x, pos.y, pos.z)
コード例 #8
0
ファイル: jenkins-test-out.py プロジェクト: RyanteckLTD/RTk
#Program that tests each pin of the RTk.GPIO port
#Import the RTk.GPIO Board
import anyio.GPIO as RTKGPIO
#And now the RPi header
import RPi.GPIO as RPIGPIO
import sys
from time import sleep

#Set the modes
RPIGPIO.setmode(RPIGPIO.BCM)
RTKGPIO.setmode(RTKGPIO.BCM)

#
#Define GPIO pins
gpios = [4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25]
#2,3,26 and 27 removed for now
errorPins = []

print("Setting up GPIO Outs on the RTK Board")
#Setup the RPi
for gpio in gpios:
	print(gpio)
	RTKGPIO.setup(gpio, RTKGPIO.OUT)
	#sleep(0.1)

print("Setting up GPIO Ins on the RPi Board")
for gpio in gpios:
	print(gpio)
	RPIGPIO.setup(gpio, RPIGPIO.IN,pull_up_down=RPIGPIO.PUD_DOWN)

print("Now Testing")
コード例 #9
0
ファイル: ultrasonic_1.py プロジェクト: RyanteckLTD/RTk
import anyio.GPIO as GPIO                    #Import GPIO library
import time                                #Import time library
GPIO.setmode(GPIO.BCM)                     #Set GPIO pin numbering 

TRIG = 23                                  #Associate pin 23 to TRIG
ECHO = 24                                  #Associate pin 24 to ECHO

print "Distance measurement in progress"

GPIO.setup(TRIG,GPIO.OUT)                  #Set pin as GPIO out
GPIO.setup(ECHO,GPIO.IN)                   #Set pin as GPIO in

while True:

  GPIO.output(TRIG, False)                 #Set TRIG as LOW
  print "Waitng For Sensor To Settle"
  time.sleep(2)                            #Delay of 2 seconds

  GPIO.output(TRIG, True)                  #Set TRIG as HIGH
  time.sleep(0.00001)                      #Delay of 0.00001 seconds
  GPIO.output(TRIG, False)                 #Set TRIG as LOW

  while GPIO.input(ECHO)==0:               #Check whether the ECHO is LOW
    pulse_start = time.time()              #Saves the last known time of LOW pulse

  while GPIO.input(ECHO)==1:               #Check whether the ECHO is HIGH
    pulse_end = time.time()                #Saves the last known time of HIGH pulse 

  pulse_duration = pulse_end - pulse_start #Get pulse duration to a variable

  distance = pulse_duration * 17150        #Multiply pulse duration by 17150 to get distance
コード例 #10
0
# testSeg7.py - Test a 7-segment display

import anyio.seg7 as display
import time

# Use this for Raspberry Pi
#import RPi.GPIO as GPIO
#LED_PINS = [10,22,25,8,7,9,11,15]

# Use this for Arduino
import anyio.GPIO as GPIO

LED_PINS = [7, 6, 14, 16, 10, 8, 9, 15]

GPIO.setmode(GPIO.BCM)

ON = False  # common-anode. Set to True for a common cathode display

display.setup(GPIO, LED_PINS, ON)

try:
    while True:
        for d in range(10):
            display.write(str(d))
            time.sleep(0.5)
finally:
    GPIO.cleanup()

# END
コード例 #11
0
#Program that tests each pin of the RTk.GPIO port
#Import the RTk.GPIO Board
import anyio.GPIO as RTKGPIO
#And now the RPi header
import RPi.GPIO as RPIGPIO
import sys
from time import sleep

#Set the modes
RPIGPIO.setmode(RPIGPIO.BCM)
RTKGPIO.setmode(RTKGPIO.BCM)

#
#Define GPIO pins
gpios = [
    4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
    24, 25
]
#2,3,26 and 27 removed for now
errorPins = []

print("Setting up GPIO Outs on the RTK Board")
#Setup the RPi
for gpio in gpios:
    print(gpio)
    RTKGPIO.setup(gpio, RTKGPIO.IN)
    #sleep(0.1)

print("Setting up GPIO Ins on the RPi Board")
for gpio in gpios:
    print(gpio)
コード例 #12
0
def setup():
  GPIO.setmode(GPIO.BCM)
  GPIO.setup(BUTTON, GPIO.IN)
コード例 #13
0
import anyio.GPIO as GPIO  #Import GPIO library
import time  #Import time library

GPIO.setmode(GPIO.BCM)  #Set GPIO pin numbering

TRIG = 23  #Associate pin 23 to TRIG
ECHO = 24  #Associate pin 24 to ECHO

print "Distance measurement in progress"

GPIO.setup(TRIG, GPIO.OUT)  #Set pin as GPIO out
GPIO.setup(ECHO, GPIO.IN)  #Set pin as GPIO in

while True:

    GPIO.output(TRIG, False)  #Set TRIG as LOW
    print "Waitng For Sensor To Settle"
    time.sleep(2)  #Delay of 2 seconds

    GPIO.output(TRIG, True)  #Set TRIG as HIGH
    time.sleep(0.00001)  #Delay of 0.00001 seconds
    GPIO.output(TRIG, False)  #Set TRIG as LOW

    while GPIO.input(ECHO) == 0:  #Check whether the ECHO is LOW
        pulse_start = time.time()  #Saves the last known time of LOW pulse

    while GPIO.input(ECHO) == 1:  #Check whether the ECHO is HIGH
        pulse_end = time.time()  #Saves the last known time of HIGH pulse

    pulse_duration = pulse_end - pulse_start  #Get pulse duration to a variable
コード例 #14
0
ファイル: countdown.py プロジェクト: whaleygeek/mc_bigbang
# BIG BANG - COUNTDOWN

# Import modules
import mcpi.minecraft as minecraft
import mcpi.block as block
import time
#import RPi.GPIO as GPIO
import anyio.GPIO as GPIO

# GPIO pins on breadboard
BANG    = 15

# Setup
mc = minecraft.Minecraft.create()
GPIO.setmode(GPIO.BCM) # use broadcom GPIO numbers
GPIO.setup(BANG, GPIO.OUT)

pos = mc.player.getTilePos()
mc.setBlock(pos.x+1, pos.y, pos.z, block.GOLD_BLOCK.id)
mc.postToChat("hit that gold block!")

# Main loop
while True:
    time.sleep(0.1)

    # Input Sensing
    bang = False
    events = mc.events.pollBlockHits()
    for e in events:
        pos = e.pos
        b = mc.getBlock(pos.x, pos.y, pos.z)