sensorPin = 17 ledPin = 4 timeoutMinSec = 30 timeoutMaxSec = 60 #lcd gpio pins rs = 26 en = 19 d4 = 13 d5 = 6 d6 = 5 d7 = 20 cols = 16 lines = 2 lcd = LCD.Adafruit_CharLCD(rs, en, d4, d5, d6, d7, cols, lines) conn = sqlite3.connect('song.db') c = conn.cursor() def SetUp(): GPIO.setwarnings(0) GPIO.setmode(GPIO.BCM) GPIO.setup(sensorPin, GPIO.IN) #, pull_up_down=GPIO.PUD_DOWN) GPIO.setup(ledPin, GPIO.OUT) GPIO.output(ledPin, 0) pygame.mixer.init() for x in range(5, 0, -1):
#!/usr/bin/env python import time import RPi.GPIO as GPIO from mfrc522 import SimpleMFRC522 import mysql.connector import Adafruit_CharLCD as LCD db = mysql.connector.connect(host="localhost", user="******", passwd="pi", database="orderpickingdb") cursor = db.cursor() reader = SimpleMFRC522() lcd = LCD.Adafruit_CharLCD(4, 24, 23, 17, 18, 22, 16, 2, 4) try: while True: lcd.clear() lcd.message('Scan Item to\npick') id, text = reader.read() cursor.execute("Select id, name, location FROM items WHERE rfid_uid=" + str(id)) result = cursor.fetchone() lcd.clear() if cursor.rowcount >= 1: lcd.message("Item " + result[1])
lcd_blue = 7 # Define LCD column and row size for 16x2 LCD. lcd_columns = 16 lcd_rows = 2 ## Initialize the LCD using the pins above. #lcd = LCD.Adafruit_RGBCharLCD(lcd_rs, lcd_en, lcd_d4, lcd_d5, lcd_d6, lcd_d7, # lcd_columns, lcd_rows, lcd_red, lcd_green, # lcd_blue, enable_pwm=True) lcd = LCD.Adafruit_CharLCD(lcd_rs, lcd_en, lcd_d4, lcd_d5, lcd_d6, lcd_d7, lcd_columns, lcd_rows, backlight=16, enable_pwm=True) # Basic colors colors = { 'red': (1.0, 0.0, 0.0), 'green': (0.0, 1.0, 0.0), 'blue': (0.0, 0.0, 1.0), 'yellow': (1.0, 1.0, 0.0), 'cyan': (0.0, 1.0, 1.0), 'magenta': (1.0, 0.0, 1.0), 'white': (1.0, 1.0, 1.0) }
]) # put all the names of the sensors together logger.info("DHT22 sensors configured: {}".format(str_sensor)) """set up the Settings object that will handle all the settings""" settings = Settings(SETTINGS_URL, SETTINGS_JSON, BARREL_ID) settings.update() """set up camera""" if CAMERA: camera = PiCamera() camera.resolution = CAMERA_RES logger.info('camera configured.') """setting up LCD display""" if LCD_PINS: # Initialize the LCD using the pins from LCD_PINS. lcd = LCD.Adafruit_CharLCD(LCD_PINS['lcd_rs'], LCD_PINS['lcd_en'], LCD_PINS['lcd_d4'], LCD_PINS['lcd_d5'], LCD_PINS['lcd_d6'], LCD_PINS['lcd_d7'], LCD_PINS['lcd_columns'], LCD_PINS['lcd_rows'], LCD_PINS['lcd_backlight']) # these will be the variables that get displayed on the LCD LCD_TOP = 'Nothing to' # 16 chars max LCD_BOT = 'display yet.' def thermostat(sun, wind, in_sensor, out_sensor, settings): """ Literally only extracts the correct data to pass to wind.fancontol() function that determines what speed the fan should be. Pass in the lights, fans, and all inputs. reads the inputs, and passes them to the correct fanspeed function (binary or PWM) """ global LCD_TOP
def __init__(self, rs, en, d4, d5, d6, d7, backlight=None, debug=False): # Initialise the Thread super(RadioDisplay, self).__init__() # Define a queue where requests for updates can be placed self.queue = Queue.Queue() # Debug mode can be used to test display without a display connected self.debug = debug # Create an empty list to hold the lines of text self.lines = ["" for _ in range(DISPLAY_ROWS)] # This thread should be daemonised self.daemon = True # Initial mode is to show menu self.displaymode = DISPLAY_CONTROLS # Define which items won't force the menu to change to the menu mode self.ignore = ["time", "menuinfo2"] # Define the templates for the modes self.templates = { "controls": [ "{mode:^14.14} {time}", "{menuinfo:^20.20}", "{menuinfo2:^20.20}", "Vol: -|{vol}|+" ], "playing": [ "{mode:^14.14} {time}", "{title:^20.20}", "{artist:^20.20}", "{album:^20.20}" ] } # Create a single string of the current template # self.text = "\n".join(self.templates[self.displaymode]) # Create an instance of the display self.lcd = LCD.Adafruit_CharLCD(rs, en, d4, d5, d6, d7, DISPLAY_COLS, DISPLAY_ROWS, backlight=backlight, invert_polarity=False) # Define a dict of parameters that will be used to format the text # to be displayed on the LCD self.params = { "mode": "PiRadio", "menuinfo": "Starting up", "menuinfo2": "", "vol": "", "time": "00:00", "title": "", "artist": "", "album": "" } # Create a list of formatted text for display self.newtxt = [ line.format(**self.params) for line in self.templates[self.displaymode] ] # Define a list to hold old menu (to compare which lines have been # updated) self.dirty = ["XX" for _ in range(4)]
GPIO.setmode(GPIO.BCM) ipin = 26 aan = False GPIO.setup(16, GPIO.OUT) GPIO.setup(21, GPIO.OUT) GPIO.setup(ipin, GPIO.IN, pull_up_down=GPIO.PUD_DOWN) rs, en, d4, d5, d6, d7, backlight, cols, rows = 25, 24, 23, 17, 18, 22, 4, 16, 2 ph = 0 lcd = LCD.Adafruit_CharLCD(rs, en, d4, d5, d6, d7, cols, rows, backlight) # Map functie voor converteren waarde ph meter def map(x, in_min, in_max, out_min, out_max): return float(x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min # WRITE functie voor log file laatste stand systeem bij unexpected powerdown def writeFile(motorStand, PH): fo = open("/home/pi/Documents/file.txt", "w") fo.write("Wat was de laatste motor stand?: \n") fo.write(str(motorStand) + "\n") fo.write("Wat was de laatst gemeten PH-waarde?: \n") fo.write(str(PH) + "\n")
from datetime import datetime import RPi.GPIO as GPIO # Raspberry Pi pin configuracion: LCD_RS = 25 # Elegir los pines correctos segun tabla BCM LCD_EN = 24 LCD_D4 = 23 LCD_D5 = 17 LCD_D6 = 18 LCD_D7 = 22 lcd_backlight = 4 lcd_columns = 16 lcd_rows = 2 # Iniciar los pines de la tabla anterior lcd = LCD.Adafruit_CharLCD(LCD_RS, LCD_EN, LCD_D4, LCD_D5, LCD_D6, LCD_D7, lcd_columns, lcd_rows, lcd_backlight) # Definir la temperatura def get_cpu_temp(): tempFile = open("/sys/class/thermal/thermal_zone0/temp") cpu_temp = tempFile.read() tempFile.close() return float(cpu_temp) / 1000 # Definir IP def get_ip_address(ifname): s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) return socket.inet_ntoa( fcntl.ioctl(s.fileno(), 0x8915, struct.pack('256s',
import Adafruit_CharLCD import serial # LCD # RS = 9 # RW -> GROUND # EN = 10 # D4 = 11 # D5 = 12 # D6 = 13 # D7 = 14 lcd = Adafruit_CharLCD.Adafruit_CharLCD(9, 10, 11, 12, 13, 14, 16, 2, 27) degree_symbol = bytearray([0xe, 0xa, 0xe, 0x0, 0x0, 0x0, 0x0, 0x0]) lcd.create_char(0, degree_symbol) lcd.clear() rfcomm = serial.Serial("/dev/rfcomm0") def lcd_set(data): lcd.clear() lcd.home() lcd.message(data) def main(): while True: data = rfcomm.readline() formatted_data = data.split("||") if formatted_data[0] == "dht":
import Adafruit_CharLCD as LCD # https://github.com/adafruit/Adafruit_Python_CharLCD import RPi.GPIO as GPIO import time GPIO.setwarnings(False) GPIO.setmode(GPIO.BCM) lcd1 = 12 lcd2 = 7 lcd3 = 8 lcd4 = 25 lcd5 = 24 lcd6 = 23 trig = 17 # trig pin of ultrasonic sensor to GPIO 17 of the RPi echo = 27 # echo pin of ultrasonic sensor to GPIO 27 of the RPi lcd = LCD.Adafruit_CharLCD(lcd1, lcd2, lcd3, lcd4, lcd5, lcd6, 0, 16, 2) GPIO.setup(trig, GPIO.OUT) GPIO.setup(echo, GPIO.IN) while True: GPIO.output(trig, True) time.sleep(0.00001) GPIO.output(trig, False) while GPIO.input(echo) == 0: pulse_s = time.time() while GPIO.input(echo) == 1: pulse_e = time.time() pulse_duration = pulse_e - pulse_s d = int(34000 * pulse_duration / 2) print(d) k = str(d) lcd.message('Distance:') lcd.message(k) lcd.message(" cm")
def __init__(self): self.lcd = LCD.Adafruit_CharLCD('P8_8', 'P8_10', 'P8_18', 'P8_16', 'P8_14', 'P8_12', 16, 2, 'P8_26')
import picamera from picamera import PiCamera import speech_recognition as sr import RPi.GPIO as GPIO GPIO.setmode(GPIO.BCM) GPIO.setup(3, GPIO.OUT) GPIO.setup(13, GPIO.OUT) GPIO.setup(21, GPIO.OUT) GPIO.setup(12, GPIO.IN) GPIO.setup(16, GPIO.IN, pull_up_down=GPIO.PUD_UP) GPIO.setup(19, GPIO.IN, pull_up_down=GPIO.PUD_UP) GPIO.setup(26, GPIO.IN, pull_up_down=GPIO.PUD_UP) lcd = LCD.Adafruit_CharLCD(9, 11, 8, 7, 5, 6, 16, 2) lcd.create_char(1,[7, 5, 7, 32, 32, 32, 32, 32]) lcd.clear() def Komunikat_głosowy(tekst): os.system( 'espeak "'+tekst+'" --stdout -a 200 -s 180 -p 40 | aplay 2>/dev/null' ) while True: r = sr.Recognizer() with sr.Microphone() as źródło_dźwięku: r.adjust_for_ambient_noise(źródło_dźwięku) try: print("Wydaj polecenie") wypowiedziane_słowo = r.listen(źródło_dźwięku) print("Przetwarzam ...")
#!/usr/bin/python import time from Adafruit_CharLCD import * PIN_RS = 25 PIN_EN = 24 PIN_DB4 = 23 PIN_DB5 = 17 PIN_DB6 = 27 PIN_DB7 = 22 if __name__ == '__main__': print "LCD Test Program" display = Adafruit_CharLCD(PIN_RS, PIN_EN, PIN_DB4, PIN_DB5, PIN_DB6, PIN_DB7, 16, 2) #display.enable_display(True) #display.home() display.clear() #display.message("Hallo!") while 1: print ">", cmd = raw_input() if cmd == "home" or cmd == "h": display.home() elif cmd == "clear" or cmd == "c": display.clear() elif cmd == "enable" or cmd == "e": display.enable_display(True)
def test_lcd(): # Raspberry Pi pin configuration: lcd_rs = 27 # Note this might need to be changed to 21 for older revision Pi's. lcd_en = 22 lcd_d4 = 25 lcd_d5 = 24 lcd_d6 = 23 lcd_d7 = 18 lcd_backlight = 4 # Define LCD column and row size for 16x2 LCD. lcd_columns = 16 lcd_rows = 2 print("Init LCD") # Initialize the LCD using the pins above. lcd = LCD.Adafruit_CharLCD(lcd_rs, lcd_en, lcd_d4, lcd_d5, lcd_d6, lcd_d7, lcd_columns, lcd_rows, lcd_backlight) lcd.enable_display(True) print("Message - 'Hello World") # Print a two line message lcd.message('Hello\nworld!') # Wait 5 seconds time.sleep(5.0) print('Show cursor') # Demo showing the cursor. lcd.clear() lcd.show_cursor(True) lcd.message('Show cursor') time.sleep(5.0) print('Blink cursor') # Demo showing the blinking cursor. lcd.clear() lcd.blink(True) lcd.message('Blink cursor') time.sleep(5.0) print("reset") # Stop blinking and showing cursor. lcd.show_cursor(False) lcd.blink(False) time.sleep(5) print("Scroll...") # Demo scrolling message right/left. lcd.clear() message = 'Scroll' lcd.message(message) for i in range(lcd_columns - len(message)): time.sleep(0.5) lcd.move_right() for i in range(lcd_columns - len(message)): time.sleep(0.5) lcd.move_left() time.sleep(5) # Demo turning backlight off and on. print('Flash backlight\nin 5 seconds...') lcd.clear() lcd.message('Flash backlight\nin 5 seconds...') time.sleep(5.0) print("Turn backlight off") # Turn backlight off. lcd.set_backlight(0) time.sleep(5.0) print("Goodbye") # Change message. lcd.clear() lcd.message('Goodbye!') # Turn backlight on. lcd.set_backlight(1) time.sleep(5)
import os #Import for file handling import glob #Import for global lcd_rs = 7 #RS of LCD is connected to GPIO 7 on PI lcd_en = 8 #EN of LCD is connected to GPIO 8 on PI lcd_d4 = 25 #D4 of LCD is connected to GPIO 25 on PI lcd_d5 = 24 #D5 of LCD is connected to GPIO 24 on PI lcd_d6 = 23 #D6 of LCD is connected to GPIO 23 on PI lcd_d7 = 18 #D7 of LCD is connected to GPIO 18 on PI lcd_backlight = 0 #LED is not connected so we assign to 0 lcd_columns = 16 #for 16*2 LCD lcd_rows = 2 #for 16*2 LCD lcd = LCD.Adafruit_CharLCD(lcd_rs, lcd_en, lcd_d4, lcd_d5, lcd_d6, lcd_d7, lcd_columns, lcd_rows, lcd_backlight) #Send all the pin details to library lcd.message('DS18B20 with Pi \n -CircuitDigest') #Give a intro message time.sleep(2) #wait for 2 secs os.system('modprobe w1-gpio') os.system('modprobe w1-therm') base_dir = '/sys/bus/w1/devices/' device_folder = glob.glob(base_dir + '28*')[0] device_file = device_folder + '/w1_slave' def get_temp(): #Fundtion to read the value of Temperature
import time # Raspberry Pi pin configuration LCD_RS = 27 LCD_EN = 22 LCD_D4 = 25 LCD_D5 = 24 LCD_D6 = 23 LCD_D7 = 18 LCD_BACKLIGHT = 4 # Define LCD column and row size for 16x2 LCD COLUMNS = 16 ROWS = 2 # Initialize the LCD using the pins above lcd = LCD.Adafruit_CharLCD(LCD_RS, LCD_EN, LCD_D4, LCD_D5, LCD_D6, LCD_D7, COLUMNS, ROWS, LCD_BACKLIGHT) zinnen = ['Hallo Richard', 'Alles goed?', 'Dit is een Pi'] zin_index = 0 while True: lcd.message(zinnen[zin_index]) zin_index += 1 if zin_index == 3: zin_index = 0 time.sleep(1.0)
doCameraSnap() sys.exit(2) if vSnapMode == 1: doCameraSnap() sys.exit(2) if vDebugMode == 0: sproc = subprocess.Popen('/home/pi/dump1090/dump1090', shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) else: print '*** DEBUG MODE ***' sproc = subprocess.Popen('cat /home/pi/test/dump1090_test2.txt', shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) lcd = Adafruit_CharLCD() lcd.clear() lcd.message("Started at " + time.strftime("%H:%M" )) ################################################################################ # Begin main read loop while True: if vDebugMode == 1: time.sleep(.001) line = sproc.stdout.readline() textblock = textblock + line if len(line) == 1: # Start of block of info
import smbus # initiate i2c bus = smbus.SMBus(1) Arduino = 12 # initiate LCD rs = 12 en = 16 D4 = 18 D5 = 23 D6 = 24 D7 = 25 LCD_columns = 16 LCD_rows = 2 lcd = LCD.Adafruit_CharLCD(rs, en, D4, D5, D6, D7, LCD_columns, LCD_rows) # initiate Special character carMap = [ 0b00000, 0b00000, 0b10100, 0b11110, 0b11111, 0b11110, 0b10100, 0b00000 ] StageMap = [ 0b10001, 0b01010, 0b00100, 0b11111, 0b11111, 0b00100, 0b01010, 0b10001 ] pointMap = [ 0b00100, 0b01111, 0b10100, 0b10100, 0b01111, 0b00101, 0b11110, 0b00100 ] NegativeHeartMap = [ 0b00000, 0b01010, 0b10101, 0b10001, 0b10001, 0b01010, 0b00100, 0b00000 ] HeartMap = [
#Screen 1 s1_rs = 21 s1_en = 20 #Screen 2 s2_rs = 25 s2_en = 24 #Screen 3 s3_rs = 26 s3_en = 19 #Screen4 s4_rs = 6 s4_en = 5 #Initialize Screens s1 = LCD.Adafruit_CharLCD(s1_rs, s1_en, lcd_d4, lcd_d5, lcd_d6, lcd_d7, lcd_columns, lcd_rows, lcd_backlight) s2 = LCD.Adafruit_CharLCD(s2_rs, s2_en, lcd_d4, lcd_d5, lcd_d6, lcd_d7, lcd_columns, lcd_rows, lcd_backlight) s3 = LCD.Adafruit_CharLCD(s3_rs, s3_en, lcd_d4, lcd_d5, lcd_d6, lcd_d7, lcd_columns, lcd_rows, lcd_backlight) s4 = LCD.Adafruit_CharLCD(s4_rs, s4_en, lcd_d4, lcd_d5, lcd_d6, lcd_d7, lcd_columns, lcd_rows, lcd_backlight) #MQTT CONFIGURATION MQTT_PATH = "" MQTT_SERVER = "" ser = serial.Serial("/dev/ttyACM0", 9600) gameRunning = False startup = True player = 0
def __init__(self): self.lcd = LCD.Adafruit_CharLCD(LCD_RS, LCD_EN, LCD_D4, LCD_D5, LCD_D6, LCD_D7, LCD_COLUMNS, LCD_LINES, LCD_BL)
TRIG4 = 27 ECHO4 = 22 TRIG5 = 4 ECHO5 = 17 print "Distance measurement in progress" lcd_rs = 26 lcd_en = 19 lcd_d4 = 13 lcd_d5 = 06 lcd_d6 = 05 lcd_d7 = 11 lcd_backlight = 2 # Define LCD column and row size for 16x2 LCD. lcd_columns = 16 lcd_rows = 2 lcd = LCD.Adafruit_CharLCD(lcd_rs, lcd_en, lcd_d4, lcd_d5, lcd_d6, lcd_d7, lcd_columns, lcd_rows, lcd_backlight) GPIO.setup(TRIG1, GPIO.OUT) #Set pin as GPIO out GPIO.setup(ECHO1, GPIO.IN) GPIO.setup(TRIG2, GPIO.OUT) #Set pin as GPIO out GPIO.setup(ECHO2, GPIO.IN) GPIO.setup(TRIG3, GPIO.OUT) #Set pin as GPIO out GPIO.setup(ECHO3, GPIO.IN) GPIO.setup(TRIG4, GPIO.OUT) #Set pin as GPIO out GPIO.setup(ECHO4, GPIO.IN) GPIO.setup(TRIG5, GPIO.OUT) #Set pin as GPIO out GPIO.setup(ECHO5, GPIO.IN) db = MySQLdb.connect("localhost", "root", "root", "smart") cursor = db.cursor() cursor.execute("DROP TABLE IF EXISTS SMARTP") sql = """CREATE TABLE SMARTP (
import random import time import Adafruit_CharLCD as LCD import RPi.GPIO as GPIO # Start Raspberry Pi configuration # Raspberry Pi pin designations lcd_rs = 27 lcd_en = 22 lcd_d4 = 25 lcd_d5 = 24 lcd_d6 = 23 lcd_d7 = 18 lcd_backlight = 4 # Define LCD column and row size for a 16x4 LCD. lcd_columns = 16 lcd_rows = 4 # Instantiate an LCD object lcd = LCD.Adafruit_CharLCD(lcd_rs, lcd_en, lcd_d4, lcd_d5, lcd_d6, lcd_d7, lcd_columns, lcd_rows, lcd_backlight) # Print a two line welcoming message lcd.message('Lets play nim\ncomputer vs human') # Wait 5 seconds time.sleep(5.0) # Clear the screen lcd.clear() # Setup GPIO pins # Set the BCM mode GPIO.setmode(GPIO.BCM) # Inputs GPIO.setup(12, GPIO.IN, pull_up_down = GPIO.PUD_DOWN) GPIO.setup(13, GPIO.IN, pull_up_down = GPIO.PUD_DOWN)