Advertisement
j33p33

Untitled

Oct 19th, 2017
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.73 KB | None | 0 0
  1. # Simple string program. Writes and updates strings.
  2. # Demo program for the I2C 16x2 Display from Ryanteck.uk
  3. # Created by Matthew Timmons-Brown for The Raspberry Pi Guy YouTube channel
  4.  
  5. # Import necessary librarie for commuunication and display use
  6. import lcddriver
  7. import time
  8. from subprocess import Popen, PIPE, STDOUT
  9.  
  10.  
  11. # Load the driver and set it to "display"
  12. # If you use something from the driver library use the "display." prefix first
  13. display = lcddriver.lcd()
  14. print ()
  15. cmd = ['audtool', '--current-song']
  16. p= Popen(cmd, shell=True, stdin=PIPE, stdout=PIPE, stderr=STDOUT, close_fds=True)
  17. for line in p.stdout:
  18. line = line.rstrip()
  19. print line
  20.  
  21. # Main body of code
  22. try:
  23. while True:
  24. # Remember that your sentences can only be 16 characters long!
  25. print("Writing to display")
  26. display.lcd_display_string("Hey jerk, wanna", 1) # Write line of text to first line of display
  27. display.lcd_display_string("kill all humans", 2) # Write line of text to second line of display
  28. time.sleep(4) # Give time for the message to be read
  29. display.lcd_clear() # Clear the display of any data
  30. display.lcd_display_string("Insert Liquor", 1) # Refresh the first line of display with a different message
  31. time.sleep(4) # Give time for the message to be read
  32. display.lcd_clear() # Clear the display of any dat
  33. display.lcd_display_string(str(line), 2)
  34. time.sleep(30)
  35.  
  36. except KeyboardInterrupt: # If there is a KeyboardInterrupt (when you press ctrl+c), exit the program and cleanup
  37. print("Cleaning up!")
  38. display.lcd_clear()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement