Untitled
unknown
plain_text
a year ago
1.2 kB
4
Indexable
Never
import RPi.GPIO as GPIO from pyfirmata import Arduino, util import chestnut.arduino from time import * analog_value = None board = Arduino((chestnut.arduino.detect_arduino_path())) util.Iterator(board).start() board.analog[0].enable_reporting() print('LED Line Program') # RPI's GPIO Pin Numbering Scheme toBCM GPIO.setmode(GPIO.BCM) # comment GPIO.setup(18, GPIO.OUT) GPIO.setup(27, GPIO.OUT) GPIO.setup(22, GPIO.OUT) GPIO.setup(23, GPIO.OUT) GPIO.setup(24, GPIO.OUT) print('Settings UP Comunications using Firmata toRedB') print('Waiting for communications to Commence') sleep(1) while True: # comment sleep(1) # comment analog_value = board.analog[0].read() # comment # comment analog_value = analog_value * 1024 print(str('the current value of the potentiometr is:') + str(analog_value)) if analog_value > 200: GPIO.output(18, True) else: GPIO.output(18, False) if analog_value > 400: GPIO.output(27, True) else: GPIO.output(27, False) if analog_value > 600: GPIO.output(22, True) else: GPIO.output(22, False) if analog_value > 800: GPIO.output(23, True) else: GPIO.output(23, False) if analog_value > 1000: GPIO.output(24, True) else: GPIO.output(24, False)