def test_lcd(): lcd = CharLCD(cols=16, rows=2, pin_rs=37, pin_e=35, pins_data=[40, 38, 36, 32, 33, 31, 29, 23], numbering_mode=GPIO.BOARD) #GPIO.setmode(GPIO.BOARD) lcd.clear() status = ["NO", "NO", "NO"] with open("indication.txt", "r") as fd: lines = fd.readlines() for i in range(3): if ("False" in lines[i]): status[i] = "NO" else: status[i] = "YES" lcd.write_string("Inet:" + status[0] + "\n") lcd.cursor_pos = (1, 0) lcd.write_string("Cam:" + status[1] + "\n") lcd.cursor_pos = (1, 8) lcd.write_string("Mav:" + status[2] + "\n") fd.close() GPIO.cleanup()
def run(self): #This is so that the light works GPIO.setwarnings(False) GPIO.setmode(GPIO.BOARD) userLightColor = 3 if self.author in self.users: userLightColor = self.users[self.author] GPIO.setup(userLightColor, GPIO.OUT) GPIO.output(userLightColor, True) #this is the lcd stuff lcd = CharLCD(cols=16, rows=2, pin_rs=22, pin_e=18, pins_data=[16, 11, 12, 15], numbering_mode=GPIO.BOARD) lcd.cursor_pos = (1, 0) lcd.write_string(self.author) for i in range(0, 2): currentPositionLCD = 0 for char in self.message: lcd.cursor_pos = (0, currentPositionLCD) #increasing the cursor position currentPositionLCD += 1 currentPositionLCD = currentPositionLCD % 16 lcd.write_string(char) time.sleep(.1) time.sleep(.5) GPIO.output(userLightColor, False) lcd.clear()
def test_boutons(affichage=False,console=False,stockage=False): listeB = [22,18,16] lcd = CharLCD(cols=16, rows=2, pin_rs=37, pin_e=35, pins_data=[33, 31, 29, 23]) GPIO.setup(listeB[0],GPIO.IN, pull_up_down=GPIO.PUD_UP) GPIO.setup(listeB[1],GPIO.IN, pull_up_down=GPIO.PUD_UP) GPIO.setup(listeB[2],GPIO.IN, pull_up_down=GPIO.PUD_UP) if affichage == True: lcd.clear() while True: if affichage == True: lcd.cursor_pos = (0, 0) lcd.write_string("Boutons : ") lcd.cursor_pos = (1, 0) lcd.write_string("1: o 2: o 3: o") bouton1 = GPIO.input(listeB[0]) if bouton1 == False: print('Button 1 Pressed') if affichage == True: lcd.cursor_pos = (1, 3) lcd.write_string("X") bouton2 = GPIO.input(listeB[1]) if bouton2 == False: print('Button 2 Pressed') if affichage == True: lcd.cursor_pos = (1, 9) lcd.write_string("X") bouton3 = GPIO.input(listeB[2]) if bouton3 == False: print('Button 3 Pressed') if affichage == True: lcd.cursor_pos = (1, 15) lcd.write_string("X") time.sleep(0.2)
54: '<', 55: '>', 56: '?' } fp = open('/dev/hidraw0', 'rb') rfid_number = "" shift = False done = False ### Begin run loop while True: ### Wait for RFID while not done: ## Get the character from the HID lcd.clear() ## Clear the LCD before writing blue_backlight.on() ## Turn on the blue backlight lcd.cursor_pos = (0, 3) ## Set cursor pos on first line lcd.write_string('Swipe Badge') buffer = fp.read(8) for c in buffer: if ord( c ) > 0: ## 40 is carriage return which signifies we are done looking for characters if int(ord(c)) == 40: done = True break ## If we are shifted then we have to use the hid2 characters. if shift: ## If it is a '2' then it is the shift key if int(ord(c)) == 2: shift = True else: # if not a 2, lookup mapping
substr_f = get_line("Folsom: ", 'folsom_f.txt', " F") substr_c = get_line("Folsom: ", 'folsom_c.txt', " C") substr_hf = get_line("Today: ", 'folsom_hf.txt', " F") substr_hc = get_line("Today: ", 'folsom_hc.txt', " C") fp = open('folsom_desc.txt', 'r') line = fp.readline() fp.close() line = line[:-1] line.ljust(15)[:15] substr_desc = (line + 15 * " ")[:15] print(substr_desc) counter = counter + 1 x = datetime.datetime.now() lcd.cursor_pos = (0, 0) lcd.write_string(x.strftime("%d %b %H:%M:%S")) lcd.cursor_pos = (1, 0) len = 11 if ((counter % len) < 2): lcd.write_string(substr_c) elif ((counter % len) <= 4): lcd.write_string(substr_f) elif ((counter % len) <= 6): lcd.write_string(substr_hc) elif ((counter % len) <= 8): lcd.write_string(substr_hf) elif ((counter % len) <= 10): lcd.write_string(substr_desc)
import RPi.GPIO as GPIO from RPLCD.gpio import CharLCD GPIO.setwarnings(False) lcd = CharLCD(cols=16, rows=2, pin_rs=37, pin_e=35, pins_data=[33, 31, 29, 23], numbering_mode=GPIO.BOARD) heart = [ 0b00000, 0b01010, 0b11111, 0b11111, 0b11111, 0b01110, 0b00100, 0b00000 ] lcd.cursor_pos = (0, 6) lcd.write_string(u'I ') lcd.create_char(0, heart) lcd.write_string(unichr(0)) lcd.cursor_pos = (1, 2) lcd.write_string(u'Raspberry Pi')
max_results = "1" stop_id = "231291" # Broadale bus stop number bus_number = "220" response = requests.get(''.join(["https://data.smartdublin.ie/cgi-bin/rtpi/realtimebusinformation?format=json",\ "&maxresults=", max_results, "&stopid=", stop_id, "&routeid=", bus_number])) while True: try: lcd.clear() json_data = response.json() # Build a string with the retrieved information data = "" bus_count = int(json_data["numberofresults"]) for i in range(0, bus_count): route = json_data["results"][i]["route"] dueTime = json_data["results"][i]["duetime"] data += "%s is due in %s minutes\n" % (route, dueTime) print(data) lcd.write_string(u"Bus Route %s: %s minutes" % (route, dueTime)) time.sleep(1) except: print("Could not find any bus data") print(response) lcd.write_string(u"Error:") lcd.cursor_pos = (1, 0) lcd.write_string(u"No bus times")
import time from RPLCD.gpio import CharLCD lcd = CharLCD(pin_rs=15, pin_rw=18, pin_e=16, pins_data=[21, 22, 23, 24], numbering_mode=GPIO.BOARD) while True: lcd.clear() lcd.cursor_pos = (0, 5) lcd.write_string('Bravo!') time.sleep(3) lcd.clear() lcd.cursor_pos = (0, 1) lcd.write_string('Je fonctionne') lcd.cursor_pos = (1, 2) lcd.write_string('parfaitement') time.sleep(3)
if (pintsPoured > 0.1): global keglevel keglevel -= pintsPoured print 'Someone just poured ' + str( pintsPoured) + ' pints of beer' litersPoured = 0 pintsPoured = 0 lastPinChange = pinChange lastPinState = pinState while continue_reading: temp_c, temp_f = read_temp() lcd.cursor_pos = (1, 0) lcd.write_string('Temp: ' + "{0:.2f}".format(temp_f) + ' F ') lcd.cursor_pos = (2, 0) lcd.write_string("{0:.2f}".format(keglevel) + ' pints left') lcd.cursor_pos = (3, 0) lcd.write_string(int(round(keglevel / startKeglevel * 20)) * "=") # Scan for cards (status, TagType) = MIFAREReader.MFRC522_Request(MIFAREReader.PICC_REQIDL) # If a card is found if status == MIFAREReader.MI_OK: print "Card detected" # Get the UID of the card (status, uid) = MIFAREReader.MFRC522_Anticoll()
#dim = (600, int(image.shape[0] * r)) # perform the actual resizing of the image and show it #resized = cv2.resize(image, dim, interpolation = cv2.INTER_AREA) encode_param = [int(cv2.IMWRITE_JPEG_QUALITY), 90] result, imgencode = cv2.imencode('.jpg', image, encode_param) data = numpy.array(imgencode) stringData = data.tostring() sock.send(str(len(stringData)).ljust(16).encode()) sock.send(stringData) str_msg = sock.recv(16).decode() print(str_msg) lcd.clear() lcd.cursor_pos = (0, 0) #line1 lcd.write_string(str_msg) lcd.cursor_pos = (0, 14) lcd.write_string("%") lcd.cursor_pos = (1, 3) #line2 lcd.write_string("confidence") #i -= 1 #camera.stop_preview() camera.close() time.sleep(2) #lcd.clear() GPIO.setwarnings(False) sock.close() print("Socket close") #decimg=cv2.imdecode(data,1) #cv2.imshow('CLIENT',decimg)
#dim = (600, int(image.shape[0] * r)) # perform the actual resizing of the image and show it #resized = cv2.resize(image, dim, interpolation = cv2.INTER_AREA) encode_param = [int(cv2.IMWRITE_JPEG_QUALITY), 90] result, imgencode = cv2.imencode('.jpg', image, encode_param) data = numpy.array(imgencode) stringData = data.tostring() sock.send(str(len(stringData)).ljust(16).encode()) sock.send(stringData) str_msg = sock.recv(32).decode() print(str_msg) lcd.clear() lcd.cursor_pos = (0, 0) #line1 lcd.write_string(str_msg) #lcd.cursor_pos = (0, 14) #lcd.write_string("%") #lcd.cursor_pos = (1, 3) #line2 #lcd.write_string("confidence") #i -= 1 #camera.stop_preview() camera.close() time.sleep(1) #lcd.clear() GPIO.setwarnings(False) sock.close() print("Socket close") #decimg=cv2.imdecode(data,1) #cv2.imshow('CLIENT',decimg)
def main(): try: lcd = CharLCD(pin_rs=11, pin_rw=13, pin_e=15, pins_data=[12, 16, 20, 21], numbering_mode=GPIO.BCM, cols=16, rows=4) lcd.clear() hour = -1 min = -1 while True: #lcd.write_string('Raspberry Pi') now = time.localtime() soilMoisture = readadc(SM, CLK, DOUT, DIN, CS) water_time = setUpWaterTime() # dang datetime right_now = datetime.now() # dang datetime lcd.cursor_pos = (0, 1) lcd.write_string(water_time.strftime("%H:%M %d/%m")) lcd.cursor_pos = (1, 1) lcd.write_string(str(soilMoisture) + " %") lcd.cursor_pos = (1, 7) lcd.write_string("weather") #noWaterHours = (right_now.day*24 + right_now.hour) -(water_time.day*24 + water_time.hour) delta = (right_now - water_time).total_seconds() noWaterHours = delta // 3600 waterPy = AutoIrrigationSystem(soilMoisture, noWaterHours) #print("I'm here") if (now.tm_hour == 12 or now.tm_hour == 6) and (now.tm_hour != hour): print("Soil moisture: ", waterPy.soilMoisture, "|", "water time: ", water_time) print("Your garden has not been watered for", waterPy.noWaterHours, "hours") current = currentWeather() forecast = forecastWeather() if (waterPy.soilMoisture < threshold and waterPy.noWaterHours >= 24 and waterPy.noWaterHours < 72): if waterPy.isRain(current): print("It's", current["description"], ". No need to water right now") elif waterPy.expectedRain(forecast) != "": print("Expecting", waterPy.expectedRain(forecast), ". No need to water right now") else: waterPy.watering(current) print("It's", current["description"]) sendMail("WaterPy", "Your plant has been watered.") elif waterPy.noWaterHours >= 72: print(current["description"]) print("It's over 3 days without water. Watering...") waterPy.watering(current) sendMail("WaterPy", "Your plant has been watered.") elif (waterPy.soilMoisture < threshold and waterPy.noWaterHours < 24): print( "Soil moisture is %.1f, under threshold but your garden has been just watered %d hours ago" % (waterPy.soilMoisture, waterPy.noWaterHours)) elif waterPy.soilMoisture > threshold: print("Soil moisture is %.1f, above threshold" % waterPy.soilMoisture) hour = now.tm_hour elif (now.tm_min % 30 == 0 and now.tm_min != min): soilMoisture = readadc(soilMoisture, CLK, DOUT, DIN, CS) current = currentWeather() forecast = forecastWeather() waterPy.saveCurrentWeather(current) waterPy.saveSoilMoisture() print( "weather info and soil moisture values has been inserted into database" ) min = now.tm_min time.sleep(1) except KeyboardInterrupt: GPIO.cleanup() lcd.clear()
from RPLCD.gpio import CharLCD lcd = CharLCD(cols=16, rows=2, pin_rw=22, pin_rs=37, pin_e=35, pins_data=[33, 31, 29, 15], numbering_mode=GPIO.BOARD, dotsize=8, charmap='A00', compat_mode=True) try: lcd.clear() lcd.cursor_pos = (0, 0) lcd.write_string(u'Thank you Rubin1') time.sleep(5) lcd.clear() lcd.write_string(u'Tacos for All!') time.sleep(5) lcd.clear() lcd.write_string(u'Thank you Rubin2') time.sleep(5) lcd.clear() lcd.write_string(u'Tacos for All!') time.sleep(5) lcd.clear() lcd.write_string(u'Thank you Rubin3') time.sleep(5) lcd.clear()
#from RPLCD import CharLCD from RPLCD.gpio import CharLCD import RPi.GPIO as GPIO import time # Logical Pins = Physical Pins D4 = 33 D5 = 31 D6 = 29 D7 = 32 pin_e = 35 pin_rs = 37 print('Pins Set') lcd = CharLCD(cols=16, rows=2, pin_rs=pin_rs, pin_e=pin_e, pins_data=[D4, D5, D6, D7], numbering_mode=GPIO.BOARD) lcd.cursor_pos = (0, 0) #row,col starting with 0 #while True: lcd.write_string( u'Yo Mama!') #\n starts new line at same pos, \r returns line at 0 pos time.sleep(6) lcd.close(clear=True) #closes display and doesnt give warning #lcd.clear() #clears display but gives warning on restart of display #time.sleep(2) print('end of script') #GPIO.cleanup()
while True: studentsId =id studentName = raw_input("Enter the Students name: ") StudentPay = raw_input("Enter the amount: ") Student_data_upload ={'StudentID' : studentsId,'StudentName' : studentName,'Amount_Paid' : StudentPay} result2 = firebaseconnection.post('/transaction/RFID_paid/Student_Information',Student_data_upload) print(result2) break #///////////////////////////////////////////// GPIO.setwarnings(False) lcd = CharLCD(numbering_mode=GPIO.BOARD, cols=16, rows=2, pin_rs=37, pin_e=35, pins_data=[33, 31, 29, 26]) lcd.clear() lcd.cursor_pos = (0,1) lcd.write_string(u'WELCOME TO ZEUS') lcd.cursor_pos = (1,8) lcd.write_string(u':)') time.sleep(2) lcd.clear() lcd.cursor_pos = (0,1) lcd.write_string(u'LIGHTINING FAST') lcd.cursor_pos = (1,1) lcd.write_string(u'PAYMENT SYSTEM') time.sleep(2) lcd.clear() lcd.cursor_pos = (0,1) lcd.write_string(u'Place your card') #////////////////////////////////////////////////// reader = SimpleMFRC522()
lcd.backlight = True input('Display should be blank. ') lcd.cursor_mode = CursorMode.blink input('The cursor should now blink. ') lcd.cursor_mode = CursorMode.line input('The cursor should now be a line. ') lcd.write_string('Hello world!') input('"Hello world!" should be on the LCD. ') assert lcd.cursor_pos == (0, 12), 'cursor_pos should now be (0, 12)' lcd.cursor_pos = (0, 15) lcd.write_string('1') lcd.cursor_pos = (1, 15) lcd.write_string('2') assert lcd.cursor_pos == (0, 0), 'cursor_pos should now be (0, 0)' input( 'Lines 1 and 2 should now be labelled with the right numbers on the right side. ' ) lcd.clear() input('Display should now be clear, cursor should be at initial position. ') lcd.cursor_pos = (0, 5) lcd.write_string('12345') input('The string should have a left offset of 5 characters. ')