Example #1
0
def setupp():
	GPIO.setmode(GPIO.BOARD)
 
	# Setup GPIO Pins
	GPIO.setup(12, GPIO.OUT)
	GPIO.setup(32, GPIO.OUT)
	GPIO.setup(33, GPIO.OUT)
	GPIO.setup(35, GPIO.OUT)
Example #2
0
File: LCD.py Project: yashb81/Code
    def __init__(self,par_RS,par_RW,par_E,par_DB4,par_DB5,par_DB6,par_DB7):
        self.__RS = par_RS
        self.__RW = par_RW
        self.__E = par_E
        self.__DB4 = par_DB4
        self.__DB5 = par_DB5
        self.__DB6 = par_DB6
        self.__DB7 = par_DB7

        allpins = [self.__RS,self.__RW,self.__E, self.__DB4, self.__DB5, self.__DB6, self.__DB7]

        GPIO.setwarnings(False)
        GPIO.setmode(GPIO.BCM)
        for pin in allpins:
            GPIO.setup(pin, GPIO.OUT)


        self.__pins = [par_DB7,par_DB6,par_DB5,par_DB4]
        self.__delay_instructie = 0.005
import RPi._GPIO as GPIO
import time

GPIO.setmode(GPIO.BCM)

ControlPin = [17, 18, 27, 22]

for pin in ControlPin:
    GPIO.setup(pin, GPIO.OUT)
    GPIO.setup(pin, GPIO.LOW)

seq = [[1, 0, 0, 0], [1, 1, 0, 0], [0, 1, 0, 0], [0, 1, 1, 0], [0, 0, 1, 0],
       [0, 0, 1, 1], [0, 0, 0, 1], [1, 0, 0, 1]]

for i in range(512):
    for halfstep in range(8):
        for pin in range(4):
            a = ControlPin[pin], seq[halfstep][pin]
            GPIO.output(ControlPin[pin], seq[halfstep][pin])
            time.sleep(0.001)

GPIO.cleanup()
def GPIO_Initialize (gpio_pin):
	GPIO.setmode(GPIO.BCM)
	GPIO.setup(gpio_pin, GPIO.IN, pull_up_down = GPIO.PUD_DOWN)
	GPIO.add_event_detect(gpio_pin, GPIO.FALLING, callback = GPIO_CallbackFunc, bouncetime = 500)
	print "Pin " + str(gpio_pin) + " set"
	return
Example #5
0
        self.ic.set_data(0xff)

    '''Test only all LOW'''
    def off(self):
        self.ic.set_data(0x00)

    def forward(self):
        self.ic.set_data(0xAA)

    def back(self):
        self.ic.set_data(0x55)
    
    
import time

GPIO.setmode(GPIO.BCM)

a = L298N_74HC595({'ds':6,'shcp':19,'stcp':13},GPIO.HIGH)
a.forward()
time.sleep(2)
a.back()
time.sleep(2)
a.forward()
time.sleep(2)
a.back()
time.sleep(2)

a.off()

GPIO.cleanup()
Example #6
0
#!/usr/bin/python
#coding: utf-8

import RPi._GPIO as GPIO
import time

GPIO.setmode(GPIO.BOARD)

SW = [7, 8, 10, 11, 12, 13, 15, 16]

for i in range(0, 8):
    GPIO.setup(SW[i], GPIO.IN, pull_up_down=GPIO.PUD_DOWN)

def isPushed(ch):
    key_in = GPIO.input(ch)
    if key_in == 0:
        return 1
    else:
        return 0

try:
    while 1:
        for i in range(0, 8):
            print i,
            print ' : ',
            print isPushed(SW[i])
        time.sleep(0.1)
except KeyboardInterrupt:
    pass

GPIO.cleanup()
Example #7
0
def setup_pins():
    GPIO.setmode(GPIO.BCM)
    # , pull_up_down=GPIO.PUD_DOWN
    GPIO.setup(power_pin, GPIO.OUT)
    GPIO.output(power_pin, 1)
Example #8
0
import RPi._GPIO as GPIO
from threading import Thread
import time
#import sys

#all reqd for gui class
import tkinter as tk  #import GUI library
from PIL import Image, ImageTk
from tkinter import messagebox
import pygame #sound

GPIO.setmode(GPIO.BOARD) #use physical pin numbering
GPIO.setwarnings(False) #disable warnings

chan_list1=[3,11,29,31,32,33]

##Setup for input & output pins
#3 Left Flipper Input (EOS Switch In) #5 Right Flipper Input (EOS Switch In)
 #7 Left Flipper Output (PWM)   #8 Right Flipper Output (PWM)
 #10,11,12,13 Pop Bumpers (Points)
GPIO.setup(chan_list1,GPIO.IN, pull_up_down=GPIO.PUD_DOWN)   
GPIO.setup([7,13],GPIO.OUT)
#Set PWM on pins 7 & 8 to 1,000 Hz. Start at 50% PWM
pwm1=GPIO.PWM(7, 1000)
pwm2=GPIO.PWM(13, 1000)
pwm1.start(100)
pwm2.start(100)

##input channels for playfield_parts
chan_list2=[15,16,18,19,21,22,23]
GPIO.setup(chan_list2, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)     #Slingshot 1 Input (Points)
Example #9
0
#!/usr/bin/python
#coding: utf-8

import RPi._GPIO as GPIO
import time

GPIO.setmode(GPIO.BOARD)

SW = [7, 8, 10, 11, 12, 13, 15, 16]

for i in range(0, 8):
    GPIO.setup(SW[i], GPIO.IN, pull_up_down=GPIO.PUD_DOWN)


def isPushed(ch):
    key_in = GPIO.input(ch)
    if key_in == 0:
        return 1
    else:
        return 0


try:
    while 1:
        for i in range(0, 8):
            print i,
            print ' : ',
            print isPushed(SW[i])
        time.sleep(0.1)
except KeyboardInterrupt:
    pass
Example #10
0
# Chuong trinh chop tat led i thoi gian ngan, mo ta pwm

import RPi._GPIO as GPIO
from time import sleep

pin = 14  #khai bao pin out
GPIO.setmode(GPIO.BCM)  #khai bao kieu pin
GPIO.setup(pin, GPIO.OUT)  #setup pin output

try:
    while True:
        GPIO.output(pin, True)  #bat led
        sleep(0.001)  #delay 1ms
        GPIO.output(pin, False)  #tat led
        sleep(0.009)  #delay 1ms

except KeyboardInterrupt:  #thoat chuong trinh khi an Ctrl + C
    print(" Thoat chuong trinh")
    GPIO.cleanup()