Beispiel #1
0
from wiringx86 import GPIOEdison as GPIO
import time
gpio = GPIO(debug=False)
time.sleep(2)
gpio.setPWMPeriod(3, 20000000)
gpio.pinMode(3, gpio.PWM)
gpio.pinMode(14, gpio.ANALOG_INPUT)
gpio.pinMode(15, gpio.ANALOG_INPUT)
gpio.pinMode(16, gpio.ANALOG_INPUT)
time.sleep(1)
while 1:
	gpio.analogWrite(3, 5)
	time.sleep(3)
	gpio.analogWrite(3, 9)
	time.sleep(2)
	print "14: " + str(gpio.analogRead(14))
	print "15: " + str(gpio.analogRead(15))
	time.sleep(1)
Beispiel #2
0
# Create a new instance of the GPIOEdison class.
# Setting debug=True gives information about the interaction with sysfs.
gpio = GPIO(debug=False)
pin = 3
brightness = 0
fadeAmount = 5

# Set pin 3 to be used as a PWM pin.
print 'Setting up pin %d' % pin
gpio.pinMode(pin, gpio.PWM)

print 'Fading pin %d now...' % pin
try:
    while(True):
        # Write brightness to the pin. The value must be between 0 and 255.
        gpio.analogWrite(pin, brightness)

        # Increment or decrement the brightness.
        brightness = brightness + fadeAmount

        # If the brightness has reached its maximum or minimum value swap
        # fadeAmount sign so we can start fading the led on the other direction.
        if brightness == 0 or brightness == 255:
            fadeAmount = -fadeAmount

        # Sleep for a while.
        time.sleep(0.03)

# When you get tired of seeing the led fading kill the loop with Ctrl-C.
except KeyboardInterrupt:
    # Leave the led turned off.
Beispiel #3
0
print 'Setting up all pins...'

# Set pin 14 to be used as an analog input GPIO pin.
for analogpin in analogpins:
    gpio.pinMode(analogpin, gpio.ANALOG_INPUT)

# Set pin 13 to be used as an output GPIO pin.
gpio.setPWMPeriod(outpin, 20000000)
gpio.pinMode(outpin, gpio.PWM)

#print 'Analog reading from pin %d now...' % analogpin
while (True):
    data = []
    level = 12
    gpio.analogWrite(outpin, level)
    for analogpin in analogpins:
        data.append(gpio.analogRead(analogpin))
    data = 'no'  # low, med, high
    if (data < 998):
        data = 'low'
        if (data < 990):
            data = 'med'
            if (data < 970):
                data = 'high'
    print "Writing to dev.studalt.ru..."
    l = requests.get(url_sensor + "&data=" + str(data))
    print "Reading gesture..."
    l = requests.get(url_finger)
    if l.status_code == 200:
        print "DEBUG: " + l.text
Beispiel #4
0
Hitting Ctrl-C stops motor.
"""

#!usr/bin/python

from wiringx86 import GPIOEdison as GPIO
import time

gpio = GPIO(debug=False)
pin = 9
pin2 = 13
fastness = 100
delta = 5

gpio.pinMode(pin, gpio.PWM)
gpio.pinMode(pin2, gpio.OUTPUT)
gpio.digitalWrite(pin2, gpio.HIGH)

try:
    while (True):
        gpio.analogWrite(pin, fastness)
        fastness = fastness + delta
        if fastness == 0 or fastness == 255:
            delta = -delta
        time.sleep(0.03)

except KeyboardInterrupt:
    gpio.analogWrite(pin, 0)
    gpio.cleanup()
Beispiel #5
0
from wiringx86 import GPIOEdison as GPIO
import time
gpio = GPIO(debug=False)
time.sleep(2)
gpio.setPWMPeriod(3, 20000000)
gpio.pinMode(3, gpio.PWM)
gpio.pinMode(14, gpio.ANALOG_INPUT)
gpio.pinMode(15, gpio.ANALOG_INPUT)
gpio.pinMode(16, gpio.ANALOG_INPUT)
time.sleep(1)
while 1:
    gpio.analogWrite(3, 5)
    time.sleep(3)
    gpio.analogWrite(3, 9)
    time.sleep(2)
    print "14: " + str(gpio.analogRead(14))
    print "15: " + str(gpio.analogRead(15))
    time.sleep(1)