Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Simple string program. Writes and updates strings.
- # Demo program for the I2C 16x2 Display from Ryanteck.uk
- # Created by Matthew Timmons-Brown for The Raspberry Pi Guy YouTube channel
- # Import necessary librarie for commuunication and display use
- import lcddriver
- import time
- from subprocess import Popen, PIPE, STDOUT
- # Load the driver and set it to "display"
- # If you use something from the driver library use the "display." prefix first
- display = lcddriver.lcd()
- print ()
- cmd = ['audtool', '--current-song']
- p= Popen(cmd, shell=True, stdin=PIPE, stdout=PIPE, stderr=STDOUT, close_fds=True)
- for line in p.stdout:
- line = line.rstrip()
- print line
- # Main body of code
- try:
- while True:
- # Remember that your sentences can only be 16 characters long!
- print("Writing to display")
- display.lcd_display_string("Hey jerk, wanna", 1) # Write line of text to first line of display
- display.lcd_display_string("kill all humans", 2) # Write line of text to second line of display
- time.sleep(4) # Give time for the message to be read
- display.lcd_clear() # Clear the display of any data
- display.lcd_display_string("Insert Liquor", 1) # Refresh the first line of display with a different message
- time.sleep(4) # Give time for the message to be read
- display.lcd_clear() # Clear the display of any dat
- display.lcd_display_string(str(line), 2)
- time.sleep(30)
- except KeyboardInterrupt: # If there is a KeyboardInterrupt (when you press ctrl+c), exit the program and cleanup
- print("Cleaning up!")
- display.lcd_clear()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement