-
Notifications
You must be signed in to change notification settings - Fork 71
added examples folder and .py files #28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import time | ||
from adafruit_circuitplayground.express import cpx | ||
|
||
while True: | ||
x, y, z = cpx.acceleration | ||
print(x, y, z) | ||
|
||
time.sleep(0.1) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# CircuitPython demo - NeoPixel | ||
|
||
import time | ||
from adafruit_circuitplayground.express import cpx | ||
|
||
|
||
# The number of pixels in the strip | ||
numpix = 10 | ||
|
||
def wheel(pos): | ||
# Input a value 0 to 255 to get a color value. | ||
# The colours are a transition r - g - b - back to r. | ||
if (pos < 0) or (pos > 255): | ||
return (0, 0, 0) | ||
if pos < 85: | ||
return (int(pos * 3), int(255 - (pos*3)), 0) | ||
elif pos < 170: | ||
pos -= 85 | ||
return (int(255 - pos*3), 0, int(pos*3)) | ||
#else: | ||
pos -= 170 | ||
return (0, int(pos*3), int(255 - pos*3)) | ||
|
||
def rainbow_cycle(wait): | ||
for j in range(255): | ||
for i in range(cpx.pixels.n): | ||
idx = int((i * 256 / len(cpx.pixels)) + j) | ||
cpx.pixels[i] = wheel(idx & 255) | ||
cpx.pixels.show() | ||
time.sleep(wait) | ||
|
||
cpx.pixels.auto_write = False | ||
cpx.pixels.brightness = 0.3 | ||
while True: | ||
rainbow_cycle(0.001) # rainbowcycle with 1ms delay per step |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from adafruit_circuitplayground.express import cpx | ||
|
||
while True: | ||
if cpx.shake(shake_threshold=20): | ||
print("Shake detected!") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
from adafruit_circuitplayground.express import cpx | ||
|
||
# Set to check for single-taps. | ||
cpx.detect_taps = 1 | ||
tap_count = 0 | ||
|
||
# We're looking for 2 single-taps before moving on. | ||
while tap_count < 2: | ||
if cpx.tapped: | ||
tap_count += 1 | ||
print("Reached 2 single-taps!") | ||
|
||
# Now switch to checking for double-taps | ||
tap_count = 0 | ||
cpx.detect_taps = 2 | ||
|
||
# We're looking for 2 double-taps before moving on. | ||
while tap_count < 2: | ||
if cpx.tapped: | ||
tap_count += 1 | ||
print("Reached 2 double-taps!") | ||
print("Done.") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
from adafruit_circuitplayground.express import cpx | ||
|
||
cpx.detect_taps = 1 | ||
|
||
while True: | ||
if cpx.tapped: | ||
print("Single tap detected!") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
from adafruit_circuitplayground.express import cpx | ||
|
||
while True: | ||
if cpx.button_a: | ||
cpx.start_tone(262) | ||
elif cpx.button_b: | ||
cpx.start_tone(294) | ||
else: | ||
cpx.stop_tone() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
from adafruit_circuitplayground.express import cpx | ||
|
||
while True: | ||
if cpx.touch_A1: | ||
print('Touched pad A1') | ||
if cpx.touch_A2: | ||
print('Touched pad A2') | ||
if cpx.touch_A3: | ||
print('Touched pad A3') | ||
if cpx.touch_A4: | ||
print('Touched pad A4') | ||
if cpx.touch_A5: | ||
print('Touched pad A5') | ||
if cpx.touch_A6: | ||
print('Touched pad A6') | ||
if cpx.touch_A7: | ||
print('Touched pad A7') |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would add an
import time
andtime.sleep(0.1)
at least into this one so it is more reasonable to read.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok