TonyGo

Untitled

Mar 18th, 2022
1,107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.33 KB | None | 0 0
  1. # Using a list of pins with loops
  2. from machine import Pin
  3. import time
  4. # Setup
  5. leds = [] # Empty list
  6. for i in range(8): # 0 - 7
  7.     led = Pin(i+6, Pin.OUT)
  8.     leds.append(led)
  9. # Test the LEDs are working - one at a time
  10. for i in range(8):
  11.     leds[i].value(1) # ON
  12.     time.sleep(0.2)
  13.     leds[i].value(0) # OFF
  14. print("Done")
Advertisement
Add Comment
Please, Sign In to add comment