Last active
February 16, 2016 15:07
-
-
Save yuma-m/5467f89b6985a4757529 to your computer and use it in GitHub Desktop.
Synchronize sensor input and LED output
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/local/bin/python | |
# -*- coding: utf-8 -*- | |
# Synchronize sensor and LED | |
from __future__ import print_function | |
import RPi.GPIO as GPIO | |
import os | |
import time | |
SENSOR_PIN = 19 | |
LED_PIN = 26 | |
GPIO.setmode(GPIO.BCM) | |
GPIO.setup(SENSOR_PIN, GPIO.IN, pull_up_down=GPIO.PUD_UP) | |
GPIO.setup(LED_PIN, GPIO.OUT) | |
while True: | |
pin_status = GPIO.input(SENSOR_PIN) | |
print(pin_status) | |
GPIO.output(LED_PIN, pin_status) | |
time.sleep(0.2) | |
GPIO.cleanup() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment