Skip to content

Commit ad5e588

Browse files
authored
Merge pull request #1527 from kattni/itsyrp
Template fix and Itsy RP examples
2 parents 365b58d + eebcfa0 commit ad5e588

3 files changed

Lines changed: 40 additions & 3 deletions

File tree

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
"""CircuitPython Digital Input Example for ItsyBitsy RP2040"""
2+
import board
3+
import digitalio
4+
5+
led = digitalio.DigitalInOut(board.LED)
6+
led.direction = digitalio.Direction.OUTPUT
7+
8+
button = digitalio.DigitalInOut(board.BUTTON)
9+
button.switch_to_input(pull=digitalio.Pull.UP)
10+
11+
while True:
12+
if not button.value:
13+
led.value = True
14+
else:
15+
led.value = False
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
"""CircuitPython NeoPixel Rainbow example for ItsyBitsy RP2040"""
2+
import time
3+
import board
4+
import neopixel
5+
from _pixelbuf import colorwheel
6+
7+
pixel = neopixel.NeoPixel(board.NEOPIXEL, 1, auto_write=False)
8+
9+
pixel.brightness = 0.3
10+
11+
12+
def rainbow(delay):
13+
for color_value in range(255):
14+
for pixels in range(1):
15+
pixel_index = (pixels * 256 // 1) + color_value
16+
pixel[pixels] = colorwheel(pixel_index & 255)
17+
pixel.show()
18+
time.sleep(delay)
19+
20+
21+
while True:
22+
rainbow(0.02)

CircuitPython_Templates/digital_input.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
button.switch_to_input(pull=digitalio.Pull.UP)
2020

2121
while True:
22-
if button.value:
23-
led.value = False
24-
else:
22+
if not button.value:
2523
led.value = True
24+
else:
25+
led.value = False

0 commit comments

Comments
 (0)