Exemple #1
0
 def __init__(self, devices=1, intensity=5, scanlimit=7):
     '''Constructor
        ScanLimit set to 7
        Intensity set to 5 out of 0:15
        Uses GPIOs 23, 24 25 as DIN, CS, and CLK respectively'''
     GP = GPIOProcessor()
     global DIN
     global CS
     global CLK
     DIN = GP.getPin34()  # Gpio 
     CS  = GP.getPin33()  # Gpio 
     CLK = GP.getPin32()  # Gpio 
     DIN.out()
     CS.out()
     CLK.out()
     global numOfDevices
     numOfDevices = devices
     for i in range(0,numOfDevices):
         self.shutDown(False,i+1)
     for i in range(0,numOfDevices):
         self.setScanLimit(scanlimit,i+1)
     for i in range(0,numOfDevices):
         self.setIntensity(intensity,i+1)
     self.clearDisplays()
     global Characters
     Characters = AL()
Exemple #2
0
]

FULL_STEP_SEQUENCE = [
    [1, 1, 0, 0],
    [0, 1, 1, 0],
    [0, 0, 1, 1],
    [1, 0, 0, 1],
]

try:
    steps_made = 0

    pins = [
        GP.getPin31(),
        GP.getPin32(),
        GP.getPin33(),
        GP.getPin34(),
    ]

    for p in pins:
        p.out()

    right = GP.getPin27()
    right.input()
    left = GP.getPin26()
    left.input()
    reset = GP.getPin24()
    reset.input()

    sequence = FULL_STEP_SEQUENCE
    i = 0
from GPIOLibrary import GPIOProcessor
import time
import math

GP = GPIOProcessor()

try:
    # Stepper Motor Controls
    A1 = GP.getPin34()    # Green
    A2 = GP.getPin24()    # Black
    B1 = GP.getPin33()    # White
    B2 = GP.getPin26()    # Yellow

    A1.out()
    A2.out()
    B1.out()
    B2.out()

    # Delay time 
    T = 0.001

    # Stepper Sequence (Forward ; Reverse)
    SS = [[[0,1,0,1],[1,0,0,1],[1,0,1,0],[0,1,1,0]],
         [[0,1,0,1],[0,1,1,0],[1,0,1,0],[1,0,0,1]]]

    # Forward/Reverse Indicator (0 - Forward, 1 - Reverse)
    FR = 0

    # Step Angle
    SA = 1.8    # 1.8 degrees per step
    
Exemple #4
0
r2 = requests.post('http://129.21.70.129:8081/newId', json = {
		"id": "mason",
		"blood_pressure": "100",
		"histamine_concentration": "1",
		"core_body_temperature": "36",
		"safe": "true"
	})

try:
    Pin29 = GP.getPin29()
    Pin29.input()

    Pin31 = GP.getPin31()
    Pin31.input()	

    Pin33 = GP.getPin33()
    Pin33.input()
	
    pinValue = Pin33.getValue()
    counter1a = 100
    counter2 = 1
    counter3 = 36

    while True:
		if Pin29.getValue() == 1:
			counter1a = counter1a + 5
		else:
			counter1a = counter1a - 5
		if counter1a >= 250:
			counter1a = 250
		elif counter1a <= 70:
from GPIOLibrary import GPIOProcessor
import time
import math

GP = GPIOProcessor()

try:
    # Stepper Motor Controls
    A1 = GP.getPin34()  # Green
    A2 = GP.getPin24()  # Black
    B1 = GP.getPin33()  # White
    B2 = GP.getPin26()  # Yellow

    A1.out()
    A2.out()
    B1.out()
    B2.out()

    # Delay time
    T = 0.001

    # Stepper Sequence (Forward ; Reverse)
    SS = [[[0, 1, 0, 1], [1, 0, 0, 1], [1, 0, 1, 0], [0, 1, 1, 0]],
          [[0, 1, 0, 1], [0, 1, 1, 0], [1, 0, 1, 0], [1, 0, 0, 1]]]

    # Forward/Reverse Indicator (0 - Forward, 1 - Reverse)
    FR = 0

    # Step Angle
    SA = 1.8  # 1.8 degrees per step
Exemple #6
0
class UltrasonicHCSR04:
    """
    Sensor Class maps DragonBoard 410c GPIO pins for Debian to the HC-SR04 ultra-sonic sensor.

    Approximate Speed of Sound through Air at 20 degrees centigrade
    343 metres per second.

    For "Shallow Water Sensor"
    Approximate Speed of Sound through Water at 15 degrees centigrade
    1464 metres per second.
    """

    def __init__(self):
        self.speed = 343  # metres per second (m/s) through Air
        # self.speed = 1464  # metres per second (m/s) through Water
        self.depth = 0

        """
        Trig (blue wire) : Pin 33 -> OpAmp Node 2 -> Ultra-sonic sensor Trig
        Echo (red wire) : Ultra-sonic sensor Echo -> Pin 30
        """
        self.gp = GPIOProcessor()

        self.trig = self.gp.getPin33()
        self.echo = self.gp.getPin34()

        self.trig.out()
        self.echo.input()

    def get_depth(self):
        return self.depth

    def set_depth(self, new_depth):
        self.depth = new_depth

    def check_depth(self):
        """
        Activate the sensor to send sound ping (Trig) and receive the echo (Echo) underwater,
        measuring the time interval and calculating and storing the value in depth.
        """
        try:
            print "Activating Shallow Water Sensor ..."
            self.trig.low()
            # time.sleep(0.000002)  # at least 2 micro-seconds
            time.sleep(0.5)  # At least 2 micro-seconds. 0.5 tested and working.
            self.trig.high()
            time.sleep(0.0001)  # At least 5 micro-seconds. 100 tested and working.
            self.trig.low()
            print "Pulse sent."

            # defining variables
            pulse_start = time.time()
            pulse_end = time.time()

            # Wait for pulse to be sent, then
            # save start time.
            # Note : Adding counter to break while loop due to weird glitch.
            counter = 10000
            while self.echo.getValue() == 0 and counter > 0:
                pulse_start = time.time()
                counter -= 1
                #  print "counter :", counter

            if self.echo.getValue() == 1:
                print "Received echo."
                while self.echo.getValue() == 1:
                    pulse_end = time.time()

            if counter == 0:
                print "No echo received for long period. Return to Manager and start again."
                self.set_depth(0)
                return False

            # Calculate total pulse duration
            # print "pulse_end time :", pulse_end
            # print "pulse_start time : ", pulse_start
            pulse_duration = pulse_end - pulse_start
            # print "pulse_duration time :", pulse_duration

            # Use pulse duration to calculate distance
            # Remember that the pulse has to go there and come back
            distance = round((pulse_duration * self.speed) / 2, 2)
            # print "distance :", distance
            self.set_depth(distance)
            return True
        except KeyboardInterrupt():
            print "Keyboard interrupt received. Cleaning up ..."
            self.gp.cleanup()
            return False
Exemple #7
0
import csv
from datetime import datetime
from GPIOLibrary import GPIOProcessor
import time

GP = GPIOProcessor()

MAX_DURATION = 120
received = [[], []]

try:
    receiverPin = GP.getPin33()
    receiverPin.out()
    start = datetime.now()
    running_time = 0

    while running_time < MAX_DURATION:
        time_delta = datetime.now() - start
        received[0].append(time_delta)
        received[1].append(receiverPin.getValue())
        running_time = time_delta.seconds

    for i in range(len(received[0])):
        received[0][i] = received[0][
            i].seconds + received[0][i].microseconds / 1000000.0

    with open('receiver_result.csv', 'wb') as csvfile:
        writer = csv.writer(csvfile,
                            delimiter=' ',
                            quotechar='|',
                            quoting=csv.QUOTE_MINIMAL)
outl = []

# Stepper motor switching sequence
seq = [[1, 0, 0, 0], [1, 1, 0, 0], [0, 1, 0, 0], [0, 1, 1, 0], [0, 0, 1, 0],
       [0, 0, 1, 1], [0, 0, 0, 1], [1, 0, 0, 1]]

stepAngle = 5.625
delay = 0.0003
#delay = 1

GP = GPIOProcessor()

try:
    # Use pins 231, 33, 30, and 34 to control motor
    out0 = GP.getPin29()  # Blue
    out1 = GP.getPin33()  # Pink
    out2 = GP.getPin30()  # Yellow
    out3 = GP.getPin34()  # Orange

    outl = [out0, out1, out2, out3]
    outl.reverse()

    # Set the pin direction to out
    for k in range(4):
        outl[k].out()

    # Rotation in degrees
    degrees = 90
    steps_per_deg = 4076.0 / 360.0
    steps = math.floor(steps_per_deg * degrees)
GP = GPIOProcessor()

# GPIO Assignments
#Din    = 27
#A1     = 34	Green
#A2     = 33	White
#A3     = 24   	Black
#A4     = 26	Yellow
#PIR    = 29
#Ind    = 30

Din = GP.getPin27()
Din.input()
A1 = GP.getPin34()
A1.out()
A2 = GP.getPin33()
A2.out()
A3 = GP.getPin24()
A3.out()
A4 = GP.getPin26()
A4.out()
PIR = GP.getPin29()
PIR.out()
PIR.low()
Ind = GP.getPin30()
Ind.out()
Ind.low()

# Remote Average Pulse
M = 800
Exemple #10
0
from GPIOLibrary import GPIOProcessor
import time

GP = GPIOProcessor()

try:
    pin = GP.getPin33()
    pin.input()

    while True:

        timeout = time.time() + 5
        count = 0
        count2 = 0
        while True:
            if pin.getValue() == 0:
                count += 1
            if pin.getValue() == 1:
                count2 += 1
            if time.time() > timeout:
                break
        print "saw " + str(count) + " zeros"
        print "saw " + str(count2) + " ones"

finally:
    GP.cleanup()
outl = []

# Stepper motor switching sequence
seq = [[1,0,0,0], [1,1,0,0], [0,1,0,0], [0,1,1,0],
       [0,0,1,0], [0,0,1,1], [0,0,0,1], [1,0,0,1]]

stepAngle = 5.625
delay = 0.0003
#delay = 1

GP = GPIOProcessor()

try:
    # Use pins 231, 33, 30, and 34 to control motor
    out0 = GP.getPin29()  # Blue
    out1 = GP.getPin33()  # Pink
    out2 = GP.getPin30()  # Yellow
    out3 = GP.getPin34()  # Orange

    outl = [out0, out1, out2, out3]
    outl.reverse()

    # Set the pin direction to out
    for k in range(4):
        outl[k].out()

    # Rotation in degrees
    degrees = 90
    steps_per_deg =4076.0/360.0
    steps = math.floor(steps_per_deg * degrees)
Exemple #12
0
GP = GPIOProcessor()

# GPIO Assignments
#Din    = 27
#A1     = 34	Green
#A2     = 33	White
#A3     = 24   	Black
#A4     = 26	Yellow
#PIR    = 29
#Ind    = 30

Din = GP.getPin27()
Din.input()
A1 = GP.getPin34()
A1.out()
A2 = GP.getPin33()
A2.out()
A3 = GP.getPin24()
A3.out()
A4 = GP.getPin26()
A4.out()
PIR = GP.getPin29()
PIR.out()
PIR.low()
Ind = GP.getPin30()
Ind.out()
Ind.low()

# Remote Average Pulse
M = 800