Skip to content

Instantly share code, notes, and snippets.

@quintaar
quintaar / led.py
Last active April 9, 2016 22:00
Simple code showing you how to use your LED with Raspberry PI
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM) #sets the GPIO numering mode
GPIO.setup(2,GPIO.OUT)
while True:
time.sleep(3)
GPIO.output(2,GPIO.LOW) #sets the pin2 to provide 0V
print 'LED should be OFF'
@quintaar
quintaar / GPIOsample.py
Last active April 4, 2016 04:32
Raspberry PI GPIO useage sample
import RPi.GPIO as GPIO
# to use GPIO number not the pin physical number
GPIO.setmode(GPIO.BCM)
"""
or to use the phisical pin numbers (1-40) instead of GPIO number
GPIO.setmode(GPIO.BOARD)
"""
# setting up pins as I/O
GPIO.setup(3, GPIO.IN) #sets GPIO3 as INPUT
@quintaar
quintaar / pir.py
Last active April 12, 2016 05:15
Raspberry PI script to connect to PIR sensor
import RPi.GPIO as GPIO
import time
sensor = 24 #your GPIO on RPI
GPIO.setmode(GPIO.BCM)
GPIO.setup(sensor, GPIO.IN, GPIO.PUD_DOWN)
current_state = False
while True:
@quintaar
quintaar / network1.py
Created February 26, 2016 06:27
Raspberry PI python - network scanner
import os
import time
import urllib
import re
import pickle
#read file containing IPs and pass the set
def readfile():
yourdevices = set()
if not os.path.exists('test1.p'): #corrected