Skip to content

Instantly share code, notes, and snippets.

@yuma-m
Last active February 16, 2016 15:07
Show Gist options
  • Save yuma-m/5467f89b6985a4757529 to your computer and use it in GitHub Desktop.
Save yuma-m/5467f89b6985a4757529 to your computer and use it in GitHub Desktop.
Synchronize sensor input and LED output
#!/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