Advertisement
ScratchMonkey

test_segments.py

Apr 29th, 2023
790
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.88 KB | None | 0 0
  1. import time
  2. from Adafruit_LED_Backpack import SevenSegment
  3.  
  4. # ===========================================================================
  5. # test display segments of 7-segment display
  6. # ===========================================================================
  7. segment = SevenSegment.SevenSegment(address=0x70)
  8.  
  9. # Initialize the display. Must be called once before using the display.
  10. segment.begin()
  11.  
  12.  
  13. # Continually update the time on a 4 char, 7-segment display
  14.  
  15. while(True):
  16.     # turn each one on for a brief flash
  17.     for pos in range(4):
  18.         for seg in range(8):
  19.             segment.clear()
  20.             segment.set_led((pos*16)+seg, True)
  21.             segment.write_display()
  22.             time.sleep(0.5)
  23.     # turn them all on for a long pulse
  24.     segment.clear()
  25.     for i in range(128):
  26.         segment.set_led(i,True)
  27.     segment.write_display()
  28.     time.sleep(0.5)
  29.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement