-
Notifications
You must be signed in to change notification settings - Fork 71
Example updates. #82
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
Example updates. #82
Changes from 2 commits
Commits
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
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 |
---|---|---|
@@ -1,10 +1,12 @@ | ||
"""This example uses the accelerometer on the Circuit Playground. It prints the values. Try moving | ||
the board to see the values change.""" | ||
""" | ||
This example uses the accelerometer on the Circuit Playground. It prints the values. Try moving | ||
the board to see the values change. If you're using Mu, open the plotter to see the values plotted. | ||
""" | ||
import time | ||
from adafruit_circuitplayground import cp | ||
|
||
while True: | ||
x, y, z = cp.acceleration | ||
print(x, y, z) | ||
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,15 @@ | ||
""" | ||
This example lights up the NeoPixels on a Circuit Playground Bluefruit in response to a loud sound. | ||
Try snapping or clapping near the board to trigger the LEDs. | ||
|
||
NOTE: This example does NOT support Circuit Playground Express. | ||
""" | ||
import time | ||
from adafruit_circuitplayground import cp | ||
|
||
while True: | ||
if cp.loud_sound(): | ||
cp.pixels.fill((50, 0, 50)) | ||
time.sleep(0.2) | ||
else: | ||
cp.pixels.fill((0, 0, 0)) |
15 changes: 15 additions & 0 deletions
15
examples/circuitplayground_bluefruit_loud_sound_threshold.py
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,15 @@ | ||
""" | ||
This example lights up the NeoPixels on a Circuit Playground Bluefruit in response to a loud sound. | ||
Try snapping or clapping near the board to trigger the LEDs. | ||
|
||
NOTE: This example does NOT support Circuit Playground Express. | ||
""" | ||
import time | ||
from adafruit_circuitplayground import cp | ||
|
||
while True: | ||
if cp.loud_sound(sound_threshold=250): | ||
cp.pixels.fill((50, 0, 50)) | ||
time.sleep(0.2) | ||
else: | ||
cp.pixels.fill((0, 0, 0)) |
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,12 @@ | ||
""" | ||
This example prints out sound levels using the sound sensor on a Circuit Playground Bluefruit. | ||
Try making sounds towards the board to see the values change. | ||
|
||
NOTE: This example does NOT support Circuit Playground Express. | ||
""" | ||
import time | ||
from adafruit_circuitplayground import cp | ||
|
||
while True: | ||
print("Sound level:", cp.sound_level) | ||
time.sleep(0.1) |
14 changes: 14 additions & 0 deletions
14
examples/circuitplayground_bluefruit_sound_level_plotter.py
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,14 @@ | ||
""" | ||
This example prints out sound levels using the sound sensor on a Circuit Playground Bluefruit. If | ||
you are using Mu, open the plotter to see the sound level plotted. Try making sounds towards the | ||
board to see the values change. | ||
|
||
NOTE: This example does NOT support Circuit Playground Express. | ||
""" | ||
import time | ||
from adafruit_circuitplayground import cp | ||
|
||
while True: | ||
print("Sound level:", cp.sound_level) | ||
print((cp.sound_level,)) | ||
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
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 @@ | ||
"""This example lights up the first NeoPixel red.""" | ||
from adafruit_circuitplayground import cp | ||
|
||
cp.pixels.brightness = 0.3 | ||
|
||
while True: | ||
cp.pixels[0] = (255, 0, 0) |
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 @@ | ||
"""This example lights up all the NeoPixel LEDs red.""" | ||
from adafruit_circuitplayground import cp | ||
|
||
while True: | ||
cp.pixels.fill((50, 0, 0)) |
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
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 @@ | ||
"""This example flashes the little red LED when the Circuit Playground is shaken.""" | ||
from adafruit_circuitplayground import cp | ||
|
||
while True: | ||
if cp.shake(shake_threshold=20): | ||
print("Shake detected!") | ||
cp.red_led = True | ||
else: | ||
cp.red_led = False |
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
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 |
---|---|---|
|
@@ -22,3 +22,5 @@ | |
tap_count += 1 | ||
print("Reached 2 double-taps!") | ||
print("Done.") | ||
while True: | ||
cp.red_led = True |
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,6 @@ | ||
"""This example prints to the serial console when you touch capacitive touch pad A1.""" | ||
from adafruit_circuitplayground import cp | ||
|
||
while True: | ||
if cp.touch_A1: | ||
print('Touched pad A1') |
File renamed without changes.
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.
If the value is 320 here, it will return 10. However, we are unlikely to hit it. If we changed this to
round(value / 320 * 9)
, I think that would fix it.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.
Good catch. Updated!