Merge branch 'master' of github.com:adafruit/Adafruit_Learning_System_Guides
This commit is contained in:
commit
c536d1b012
27 changed files with 1969 additions and 0 deletions
433
.pylintrc
Normal file
433
.pylintrc
Normal file
|
|
@ -0,0 +1,433 @@
|
|||
[MASTER]
|
||||
|
||||
# A comma-separated list of package or module names from where C extensions may
|
||||
# be loaded. Extensions are loading into the active Python interpreter and may
|
||||
# run arbitrary code
|
||||
extension-pkg-whitelist=
|
||||
|
||||
# Add files or directories to the blacklist. They should be base names, not
|
||||
# paths.
|
||||
ignore=CVS
|
||||
|
||||
# Add files or directories matching the regex patterns to the blacklist. The
|
||||
# regex matches against base names, not paths.
|
||||
ignore-patterns=
|
||||
|
||||
# Python code to execute, usually for sys.path manipulation such as
|
||||
# pygtk.require().
|
||||
#init-hook=
|
||||
|
||||
# Use multiple processes to speed up Pylint.
|
||||
# jobs=1
|
||||
jobs=2
|
||||
|
||||
# List of plugins (as comma separated values of python modules names) to load,
|
||||
# usually to register additional checkers.
|
||||
load-plugins=
|
||||
|
||||
# Pickle collected data for later comparisons.
|
||||
persistent=yes
|
||||
|
||||
# Specify a configuration file.
|
||||
#rcfile=
|
||||
|
||||
# Allow loading of arbitrary C extensions. Extensions are imported into the
|
||||
# active Python interpreter and may run arbitrary code.
|
||||
unsafe-load-any-extension=no
|
||||
|
||||
|
||||
[MESSAGES CONTROL]
|
||||
|
||||
# Only show warnings with the listed confidence levels. Leave empty to show
|
||||
# all. Valid levels: HIGH, INFERENCE, INFERENCE_FAILURE, UNDEFINED
|
||||
confidence=
|
||||
|
||||
# Disable the message, report, category or checker with the given id(s). You
|
||||
# can either give multiple identifiers separated by comma (,) or put this
|
||||
# option multiple times (only on the command line, not in the configuration
|
||||
# file where it should appear only once).You can also use "--disable=all" to
|
||||
# disable everything first and then reenable specific checks. For example, if
|
||||
# you want to run only the similarities checker, you can use "--disable=all
|
||||
# --enable=similarities". If you want to run only the classes checker, but have
|
||||
# no Warning level messages displayed, use"--disable=all --enable=classes
|
||||
# --disable=W"
|
||||
# disable=import-error,print-statement,parameter-unpacking,unpacking-in-except,old-raise-syntax,backtick,long-suffix,old-ne-operator,old-octal-literal,import-star-module-level,raw-checker-failed,bad-inline-option,locally-disabled,locally-enabled,file-ignored,suppressed-message,useless-suppression,deprecated-pragma,apply-builtin,basestring-builtin,buffer-builtin,cmp-builtin,coerce-builtin,execfile-builtin,file-builtin,long-builtin,raw_input-builtin,reduce-builtin,standarderror-builtin,unicode-builtin,xrange-builtin,coerce-method,delslice-method,getslice-method,setslice-method,no-absolute-import,old-division,dict-iter-method,dict-view-method,next-method-called,metaclass-assignment,indexing-exception,raising-string,reload-builtin,oct-method,hex-method,nonzero-method,cmp-method,input-builtin,round-builtin,intern-builtin,unichr-builtin,map-builtin-not-iterating,zip-builtin-not-iterating,range-builtin-not-iterating,filter-builtin-not-iterating,using-cmp-argument,eq-without-hash,div-method,idiv-method,rdiv-method,exception-message-attribute,invalid-str-codec,sys-max-int,bad-python3-import,deprecated-string-function,deprecated-str-translate-call
|
||||
disable=too-many-instance-attributes,len-as-condition,too-few-public-methods,anomalous-backslash-in-string,no-else-return,simplifiable-if-statement,too-many-arguments,duplicate-code,no-name-in-module,no-member,print-statement,parameter-unpacking,unpacking-in-except,old-raise-syntax,backtick,long-suffix,old-ne-operator,old-octal-literal,import-star-module-level,raw-checker-failed,bad-inline-option,locally-disabled,locally-enabled,file-ignored,suppressed-message,useless-suppression,deprecated-pragma,apply-builtin,basestring-builtin,buffer-builtin,cmp-builtin,coerce-builtin,execfile-builtin,file-builtin,long-builtin,raw_input-builtin,reduce-builtin,standarderror-builtin,unicode-builtin,xrange-builtin,coerce-method,delslice-method,getslice-method,setslice-method,no-absolute-import,old-division,dict-iter-method,dict-view-method,next-method-called,metaclass-assignment,indexing-exception,raising-string,reload-builtin,oct-method,hex-method,nonzero-method,cmp-method,input-builtin,round-builtin,intern-builtin,unichr-builtin,map-builtin-not-iterating,zip-builtin-not-iterating,range-builtin-not-iterating,filter-builtin-not-iterating,using-cmp-argument,eq-without-hash,div-method,idiv-method,rdiv-method,exception-message-attribute,invalid-str-codec,sys-max-int,bad-python3-import,deprecated-string-function,deprecated-str-translate-call,import-error,missing-docstring,invalid-name,bad-whitespace, --msg-template='{path} {line}: {msg} ({symbol})' */*.py
|
||||
|
||||
# Enable the message, report, category or checker with the given id(s). You can
|
||||
# either give multiple identifier separated by comma (,) or put this option
|
||||
# multiple time (only on the command line, not in the configuration file where
|
||||
# it should appear only once). See also the "--disable" option for examples.
|
||||
enable=
|
||||
|
||||
|
||||
[REPORTS]
|
||||
|
||||
# Python expression which should return a note less than 10 (10 is the highest
|
||||
# note). You have access to the variables errors warning, statement which
|
||||
# respectively contain the number of errors / warnings messages and the total
|
||||
# number of statements analyzed. This is used by the global evaluation report
|
||||
# (RP0004).
|
||||
evaluation=10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10)
|
||||
|
||||
# Template used to display messages. This is a python new-style format string
|
||||
# used to format the message information. See doc for all details
|
||||
#msg-template=
|
||||
|
||||
# Set the output format. Available formats are text, parseable, colorized, json
|
||||
# and msvs (visual studio).You can also give a reporter class, eg
|
||||
# mypackage.mymodule.MyReporterClass.
|
||||
output-format=text
|
||||
|
||||
# Tells whether to display a full report or only the messages
|
||||
reports=no
|
||||
|
||||
# Activate the evaluation score.
|
||||
score=yes
|
||||
|
||||
|
||||
[REFACTORING]
|
||||
|
||||
# Maximum number of nested blocks for function / method body
|
||||
max-nested-blocks=5
|
||||
|
||||
|
||||
[LOGGING]
|
||||
|
||||
# Logging modules to check that the string format arguments are in logging
|
||||
# function parameter format
|
||||
logging-modules=logging
|
||||
|
||||
|
||||
[SPELLING]
|
||||
|
||||
# Spelling dictionary name. Available dictionaries: none. To make it working
|
||||
# install python-enchant package.
|
||||
spelling-dict=
|
||||
|
||||
# List of comma separated words that should not be checked.
|
||||
spelling-ignore-words=
|
||||
|
||||
# A path to a file that contains private dictionary; one word per line.
|
||||
spelling-private-dict-file=
|
||||
|
||||
# Tells whether to store unknown words to indicated private dictionary in
|
||||
# --spelling-private-dict-file option instead of raising a message.
|
||||
spelling-store-unknown-words=no
|
||||
|
||||
|
||||
[MISCELLANEOUS]
|
||||
|
||||
# List of note tags to take in consideration, separated by a comma.
|
||||
# notes=FIXME,XXX,TODO
|
||||
notes=FIXME,XXX
|
||||
|
||||
|
||||
[TYPECHECK]
|
||||
|
||||
# List of decorators that produce context managers, such as
|
||||
# contextlib.contextmanager. Add to this list to register other decorators that
|
||||
# produce valid context managers.
|
||||
contextmanager-decorators=contextlib.contextmanager
|
||||
|
||||
# List of members which are set dynamically and missed by pylint inference
|
||||
# system, and so shouldn't trigger E1101 when accessed. Python regular
|
||||
# expressions are accepted.
|
||||
generated-members=
|
||||
|
||||
# Tells whether missing members accessed in mixin class should be ignored. A
|
||||
# mixin class is detected if its name ends with "mixin" (case insensitive).
|
||||
ignore-mixin-members=yes
|
||||
|
||||
# This flag controls whether pylint should warn about no-member and similar
|
||||
# checks whenever an opaque object is returned when inferring. The inference
|
||||
# can return multiple potential results while evaluating a Python object, but
|
||||
# some branches might not be evaluated, which results in partial inference. In
|
||||
# that case, it might be useful to still emit no-member and other checks for
|
||||
# the rest of the inferred objects.
|
||||
ignore-on-opaque-inference=yes
|
||||
|
||||
# List of class names for which member attributes should not be checked (useful
|
||||
# for classes with dynamically set attributes). This supports the use of
|
||||
# qualified names.
|
||||
ignored-classes=optparse.Values,thread._local,_thread._local
|
||||
|
||||
# List of module names for which member attributes should not be checked
|
||||
# (useful for modules/projects where namespaces are manipulated during runtime
|
||||
# and thus existing member attributes cannot be deduced by static analysis. It
|
||||
# supports qualified module names, as well as Unix pattern matching.
|
||||
ignored-modules=
|
||||
|
||||
# Show a hint with possible names when a member name was not found. The aspect
|
||||
# of finding the hint is based on edit distance.
|
||||
missing-member-hint=yes
|
||||
|
||||
# The minimum edit distance a name should have in order to be considered a
|
||||
# similar match for a missing member name.
|
||||
missing-member-hint-distance=1
|
||||
|
||||
# The total number of similar names that should be taken in consideration when
|
||||
# showing a hint for a missing member.
|
||||
missing-member-max-choices=1
|
||||
|
||||
|
||||
[VARIABLES]
|
||||
|
||||
# List of additional names supposed to be defined in builtins. Remember that
|
||||
# you should avoid to define new builtins when possible.
|
||||
additional-builtins=
|
||||
|
||||
# Tells whether unused global variables should be treated as a violation.
|
||||
allow-global-unused-variables=yes
|
||||
|
||||
# List of strings which can identify a callback function by name. A callback
|
||||
# name must start or end with one of those strings.
|
||||
callbacks=cb_,_cb
|
||||
|
||||
# A regular expression matching the name of dummy variables (i.e. expectedly
|
||||
# not used).
|
||||
dummy-variables-rgx=_+$|(_[a-zA-Z0-9_]*[a-zA-Z0-9]+?$)|dummy|^ignored_|^unused_
|
||||
|
||||
# Argument names that match this expression will be ignored. Default to name
|
||||
# with leading underscore
|
||||
ignored-argument-names=_.*|^ignored_|^unused_
|
||||
|
||||
# Tells whether we should check for unused import in __init__ files.
|
||||
init-import=no
|
||||
|
||||
# List of qualified module names which can have objects that can redefine
|
||||
# builtins.
|
||||
redefining-builtins-modules=six.moves,future.builtins
|
||||
|
||||
|
||||
[FORMAT]
|
||||
|
||||
# Expected format of line ending, e.g. empty (any line ending), LF or CRLF.
|
||||
# expected-line-ending-format=
|
||||
expected-line-ending-format=LF
|
||||
|
||||
# Regexp for a line that is allowed to be longer than the limit.
|
||||
ignore-long-lines=^\s*(# )?<?https?://\S+>?$
|
||||
|
||||
# Number of spaces of indent required inside a hanging or continued line.
|
||||
indent-after-paren=4
|
||||
|
||||
# String used as indentation unit. This is usually " " (4 spaces) or "\t" (1
|
||||
# tab).
|
||||
indent-string=' '
|
||||
|
||||
# Maximum number of characters on a single line.
|
||||
max-line-length=100
|
||||
|
||||
# Maximum number of lines in a module
|
||||
max-module-lines=1000
|
||||
|
||||
# List of optional constructs for which whitespace checking is disabled. `dict-
|
||||
# separator` is used to allow tabulation in dicts, etc.: {1 : 1,\n222: 2}.
|
||||
# `trailing-comma` allows a space between comma and closing bracket: (a, ).
|
||||
# `empty-line` allows space-only lines.
|
||||
no-space-check=trailing-comma,dict-separator
|
||||
|
||||
# Allow the body of a class to be on the same line as the declaration if body
|
||||
# contains single statement.
|
||||
single-line-class-stmt=no
|
||||
|
||||
# Allow the body of an if to be on the same line as the test if there is no
|
||||
# else.
|
||||
single-line-if-stmt=no
|
||||
|
||||
|
||||
[SIMILARITIES]
|
||||
|
||||
# Ignore comments when computing similarities.
|
||||
ignore-comments=yes
|
||||
|
||||
# Ignore docstrings when computing similarities.
|
||||
ignore-docstrings=yes
|
||||
|
||||
# Ignore imports when computing similarities.
|
||||
ignore-imports=no
|
||||
|
||||
# Minimum lines number of a similarity.
|
||||
min-similarity-lines=4
|
||||
|
||||
|
||||
[BASIC]
|
||||
|
||||
# Naming hint for argument names
|
||||
argument-name-hint=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$
|
||||
|
||||
# Regular expression matching correct argument names
|
||||
argument-rgx=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$
|
||||
|
||||
# Naming hint for attribute names
|
||||
attr-name-hint=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$
|
||||
|
||||
# Regular expression matching correct attribute names
|
||||
attr-rgx=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$
|
||||
|
||||
# Bad variable names which should always be refused, separated by a comma
|
||||
bad-names=foo,bar,baz,toto,tutu,tata
|
||||
|
||||
# Naming hint for class attribute names
|
||||
class-attribute-name-hint=([A-Za-z_][A-Za-z0-9_]{2,30}|(__.*__))$
|
||||
|
||||
# Regular expression matching correct class attribute names
|
||||
class-attribute-rgx=([A-Za-z_][A-Za-z0-9_]{2,30}|(__.*__))$
|
||||
|
||||
# Naming hint for class names
|
||||
# class-name-hint=[A-Z_][a-zA-Z0-9]+$
|
||||
class-name-hint=[A-Z_][a-zA-Z0-9_]+$
|
||||
|
||||
# Regular expression matching correct class names
|
||||
# class-rgx=[A-Z_][a-zA-Z0-9]+$
|
||||
class-rgx=[A-Z_][a-zA-Z0-9_]+$
|
||||
|
||||
# Naming hint for constant names
|
||||
const-name-hint=(([A-Z_][A-Z0-9_]*)|(__.*__))$
|
||||
|
||||
# Regular expression matching correct constant names
|
||||
const-rgx=(([A-Z_][A-Z0-9_]*)|(__.*__))$
|
||||
|
||||
# Minimum line length for functions/classes that require docstrings, shorter
|
||||
# ones are exempt.
|
||||
docstring-min-length=-1
|
||||
|
||||
# Naming hint for function names
|
||||
function-name-hint=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$
|
||||
|
||||
# Regular expression matching correct function names
|
||||
function-rgx=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$
|
||||
|
||||
# Good variable names which should always be accepted, separated by a comma
|
||||
# good-names=i,j,k,ex,Run,_
|
||||
good-names=r,g,b,w,i,j,k,n,x,y,z,ex,ok,Run,_
|
||||
|
||||
# Include a hint for the correct naming format with invalid-name
|
||||
include-naming-hint=no
|
||||
|
||||
# Naming hint for inline iteration names
|
||||
inlinevar-name-hint=[A-Za-z_][A-Za-z0-9_]*$
|
||||
|
||||
# Regular expression matching correct inline iteration names
|
||||
inlinevar-rgx=[A-Za-z_][A-Za-z0-9_]*$
|
||||
|
||||
# Naming hint for method names
|
||||
method-name-hint=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$
|
||||
|
||||
# Regular expression matching correct method names
|
||||
method-rgx=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$
|
||||
|
||||
# Naming hint for module names
|
||||
module-name-hint=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$
|
||||
|
||||
# Regular expression matching correct module names
|
||||
module-rgx=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$
|
||||
|
||||
# Colon-delimited sets of names that determine each other's naming style when
|
||||
# the name regexes allow several styles.
|
||||
name-group=
|
||||
|
||||
# Regular expression which should only match function or class names that do
|
||||
# not require a docstring.
|
||||
no-docstring-rgx=^_
|
||||
|
||||
# List of decorators that produce properties, such as abc.abstractproperty. Add
|
||||
# to this list to register other decorators that produce valid properties.
|
||||
property-classes=abc.abstractproperty
|
||||
|
||||
# Naming hint for variable names
|
||||
variable-name-hint=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$
|
||||
|
||||
# Regular expression matching correct variable names
|
||||
variable-rgx=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$
|
||||
|
||||
|
||||
[IMPORTS]
|
||||
|
||||
# Allow wildcard imports from modules that define __all__.
|
||||
allow-wildcard-with-all=no
|
||||
|
||||
# Analyse import fallback blocks. This can be used to support both Python 2 and
|
||||
# 3 compatible code, which means that the block might have code that exists
|
||||
# only in one or another interpreter, leading to false positives when analysed.
|
||||
analyse-fallback-blocks=no
|
||||
|
||||
# Deprecated modules which should not be used, separated by a comma
|
||||
deprecated-modules=optparse,tkinter.tix
|
||||
|
||||
# Create a graph of external dependencies in the given file (report RP0402 must
|
||||
# not be disabled)
|
||||
ext-import-graph=
|
||||
|
||||
# Create a graph of every (i.e. internal and external) dependencies in the
|
||||
# given file (report RP0402 must not be disabled)
|
||||
import-graph=
|
||||
|
||||
# Create a graph of internal dependencies in the given file (report RP0402 must
|
||||
# not be disabled)
|
||||
int-import-graph=
|
||||
|
||||
# Force import order to recognize a module as part of the standard
|
||||
# compatibility libraries.
|
||||
known-standard-library=
|
||||
|
||||
# Force import order to recognize a module as part of a third party library.
|
||||
known-third-party=enchant
|
||||
|
||||
|
||||
[CLASSES]
|
||||
|
||||
# List of method names used to declare (i.e. assign) instance attributes.
|
||||
defining-attr-methods=__init__,__new__,setUp
|
||||
|
||||
# List of member names, which should be excluded from the protected access
|
||||
# warning.
|
||||
exclude-protected=_asdict,_fields,_replace,_source,_make
|
||||
|
||||
# List of valid names for the first argument in a class method.
|
||||
valid-classmethod-first-arg=cls
|
||||
|
||||
# List of valid names for the first argument in a metaclass class method.
|
||||
valid-metaclass-classmethod-first-arg=mcs
|
||||
|
||||
|
||||
[DESIGN]
|
||||
|
||||
# Maximum number of arguments for function / method
|
||||
max-args=5
|
||||
|
||||
# Maximum number of attributes for a class (see R0902).
|
||||
# max-attributes=7
|
||||
max-attributes=11
|
||||
|
||||
# Maximum number of boolean expressions in a if statement
|
||||
max-bool-expr=5
|
||||
|
||||
# Maximum number of branch for function / method body
|
||||
max-branches=12
|
||||
|
||||
# Maximum number of locals for function / method body
|
||||
max-locals=15
|
||||
|
||||
# Maximum number of parents for a class (see R0901).
|
||||
max-parents=7
|
||||
|
||||
# Maximum number of public methods for a class (see R0904).
|
||||
max-public-methods=20
|
||||
|
||||
# Maximum number of return / yield for function / method body
|
||||
max-returns=6
|
||||
|
||||
# Maximum number of statements in function / method body
|
||||
max-statements=50
|
||||
|
||||
# Minimum number of public methods for a class (see R0903).
|
||||
min-public-methods=1
|
||||
|
||||
|
||||
[EXCEPTIONS]
|
||||
|
||||
# Exceptions that will emit a warning when being caught. Defaults to
|
||||
# "Exception"
|
||||
overgeneral-exceptions=Exception
|
||||
14
.travis.yml
Normal file
14
.travis.yml
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
dist: trusty
|
||||
sudo: false
|
||||
language: python
|
||||
python:
|
||||
- "3.6"
|
||||
|
||||
cache:
|
||||
pip: true
|
||||
|
||||
install:
|
||||
- pip install pylint
|
||||
|
||||
script:
|
||||
- ./pylint_check
|
||||
BIN
Animatronic_Hand/CRICKIT_servos_speaker.fzz
Normal file
BIN
Animatronic_Hand/CRICKIT_servos_speaker.fzz
Normal file
Binary file not shown.
BIN
Animatronic_Hand/audioanim.png
Normal file
BIN
Animatronic_Hand/audioanim.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 390 KiB |
97
Animatronic_Hand/binary_counting.py
Normal file
97
Animatronic_Hand/binary_counting.py
Normal file
|
|
@ -0,0 +1,97 @@
|
|||
# Animatronic Hand
|
||||
# Binary Counting on four fingers up to 15
|
||||
from digitalio import DigitalInOut, Direction, Pull
|
||||
import audioio
|
||||
from adafruit_seesaw.seesaw import Seesaw
|
||||
from adafruit_seesaw.pwmout import PWMOut
|
||||
from adafruit_motor import servo
|
||||
from busio import I2C
|
||||
import board
|
||||
import time
|
||||
|
||||
# Create I2C and seesaw objuect
|
||||
i2c = I2C(board.SCL, board.SDA)
|
||||
ss = Seesaw(i2c)
|
||||
|
||||
#################### CPX switch
|
||||
# use the CPX onboard switch to turn on/off (helps calibrate)
|
||||
switch = DigitalInOut(board.SLIDE_SWITCH)
|
||||
switch.direction = Direction.INPUT
|
||||
switch.pull = Pull.UP
|
||||
|
||||
#################### Audio setup
|
||||
print("Let's count in binary.")
|
||||
wavfiles = ["one.wav", "two.wav", "three.wav", "four.wav", "five.wav", "six.wav",
|
||||
"seven.wav", "eight.wav", "nine.wav", "ten.wav", "eleven.wav",
|
||||
"twelve.wav", "thirteen.wav", "fourteen.wav", "fifteen.wav"]
|
||||
introfile = "intro.wav"
|
||||
|
||||
cpx_audio = audioio.AudioOut(board.A0)
|
||||
def play_file(wavfile):
|
||||
with open(wavfile, "rb") as f:
|
||||
wav = audioio.WaveFile(f)
|
||||
cpx_audio.play(wav)
|
||||
while cpx_audio.playing:
|
||||
pass
|
||||
|
||||
#################### 4 Servos
|
||||
servos = []
|
||||
for ss_pin in (17, 16, 15, 14):
|
||||
pwm = PWMOut(ss, ss_pin)
|
||||
pwm.frequency = 50
|
||||
_servo = servo.Servo(pwm)
|
||||
_servo.angle = 90 # starting angle, middle
|
||||
servos.append(_servo)
|
||||
|
||||
# Which servos to actuate for each number
|
||||
counting = [
|
||||
[3],
|
||||
[2],
|
||||
[3, 2],
|
||||
[1],
|
||||
[1, 3],
|
||||
[1, 2],
|
||||
[3, 2, 1],
|
||||
[0],
|
||||
[0, 3],
|
||||
[0, 2],
|
||||
[0, 3, 2],
|
||||
[0, 1],
|
||||
[0, 3, 1],
|
||||
[0, 2, 1],
|
||||
[0, 3, 2, 1]
|
||||
]
|
||||
|
||||
play_file(introfile)
|
||||
|
||||
while True:
|
||||
if not switch.value:
|
||||
continue
|
||||
|
||||
# the CPX switch is on, so do things
|
||||
for i in range(4): # close the fist
|
||||
servos[i].angle = 0 # close the fingers
|
||||
print("Servo %s angle = 0" % i )
|
||||
time.sleep(.2)
|
||||
|
||||
time.sleep(1) # pause a moment
|
||||
|
||||
for i in range(len(counting)):
|
||||
# close all the counting fingers between numbers
|
||||
for k in range(4):
|
||||
servos[k].angle = 0 # close
|
||||
print("\t\tServo #%d angle 0" % k)
|
||||
time.sleep(0.3)
|
||||
|
||||
print("Number #%d \tfingers: %s" % (i+1, counting[i]))
|
||||
|
||||
# open just the indicated fingers when counting
|
||||
for j in range(len(counting[i])):
|
||||
servos[counting[i][j]].angle = 180 # open
|
||||
print("\t\tServo #%d angle 180" % counting[i][j])
|
||||
time.sleep(0.3)
|
||||
# say it!
|
||||
play_file(wavfiles[i])
|
||||
# hold for a bit of time
|
||||
time.sleep(0.3)
|
||||
print("...")
|
||||
66
Animatronic_Hand/touch.py
Normal file
66
Animatronic_Hand/touch.py
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
# Animatronic Hand
|
||||
# CPX with CRICKIT and four servos
|
||||
# touch four cap pads to close the fingers
|
||||
|
||||
from digitalio import DigitalInOut, Direction, Pull
|
||||
from adafruit_seesaw.seesaw import Seesaw
|
||||
from adafruit_seesaw.pwmout import PWMOut
|
||||
from adafruit_motor import servo
|
||||
from busio import I2C
|
||||
import board
|
||||
|
||||
i2c = I2C(board.SCL, board.SDA)
|
||||
ss = Seesaw(i2c)
|
||||
|
||||
#################### CPX switch
|
||||
# use the CPX onboard switch to turn on/off (helps calibrate)
|
||||
switch = DigitalInOut(board.SLIDE_SWITCH)
|
||||
switch.direction = Direction.INPUT
|
||||
switch.pull = Pull.UP
|
||||
|
||||
#################### 4 Servos
|
||||
servos = []
|
||||
for ss_pin in (17, 16, 15, 14):
|
||||
pwm = PWMOut(ss, ss_pin)
|
||||
pwm.frequency = 50
|
||||
_servo = servo.Servo(pwm)
|
||||
_servo.angle = 90 # starting angle, middle
|
||||
servos.append(_servo)
|
||||
|
||||
CAPTOUCH_THRESH = 500 # threshold for touch detection
|
||||
|
||||
cap_state = [False, False, False, False]
|
||||
cap_justtouched = [False, False, False, False]
|
||||
cap_justreleased = [False, False, False, False]
|
||||
|
||||
curl_finger = [False, False, False, False]
|
||||
finger_name = ['Index', 'Middle', 'Ring', 'Pinky']
|
||||
|
||||
while True:
|
||||
if not switch.value: # the CPX switch is off, so do nothing
|
||||
continue
|
||||
# Check the cap touch sensors to see if they're being touched
|
||||
for i in range(4):
|
||||
touch_val = ss.touch_read(i)
|
||||
cap_justtouched[i] = False
|
||||
cap_justreleased[i] = False
|
||||
|
||||
if touch_val > CAPTOUCH_THRESH:
|
||||
# print("CT" + str(i + 1) + " touched! value: " + str(touch_val))
|
||||
if not cap_state[i]:
|
||||
cap_justtouched[i] = True
|
||||
print("%s finger bent." % finger_name[i])
|
||||
servos[i].angle = 0
|
||||
cap_state[i] = True
|
||||
|
||||
else:
|
||||
if cap_state[i]:
|
||||
cap_justreleased[i] = True
|
||||
print("%s finger straightened." % finger_name[i])
|
||||
servos[i].angle = 180
|
||||
# print("CT" + str(i + 1) + " released!")
|
||||
|
||||
cap_state[i] = False
|
||||
|
||||
if cap_justtouched[i]:
|
||||
curl_finger[i] = not curl_finger[i]
|
||||
12
Crickits/flying_trapeze/boot.py
Normal file
12
Crickits/flying_trapeze/boot.py
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
# Save as boot.py to turn on/off datalogging capability
|
||||
|
||||
import digitalio
|
||||
import board
|
||||
import storage
|
||||
|
||||
switch = digitalio.DigitalInOut(board.D7) # For Circuit Playground Express
|
||||
switch.direction = digitalio.Direction.INPUT
|
||||
switch.pull = digitalio.Pull.UP
|
||||
|
||||
# If the switch pin is connected to ground CircuitPython can write to the drive
|
||||
storage.remount("/", switch.value)
|
||||
106
Crickits/flying_trapeze/code.py
Normal file
106
Crickits/flying_trapeze/code.py
Normal file
|
|
@ -0,0 +1,106 @@
|
|||
from digitalio import DigitalInOut, Direction, Pull
|
||||
import adafruit_lis3dh
|
||||
from busio import I2C
|
||||
from adafruit_seesaw.seesaw import Seesaw
|
||||
from adafruit_seesaw.pwmout import PWMOut
|
||||
from adafruit_motor import servo
|
||||
import neopixel
|
||||
import board
|
||||
import time
|
||||
import gc
|
||||
|
||||
# create accelerometer
|
||||
i2c1 = I2C(board.ACCELEROMETER_SCL, board.ACCELEROMETER_SDA)
|
||||
lis3dh = adafruit_lis3dh.LIS3DH_I2C(i2c1, address=0x19)
|
||||
lis3dh.range = adafruit_lis3dh.RANGE_8_G
|
||||
|
||||
# Create seesaw object
|
||||
i2c = I2C(board.SCL, board.SDA)
|
||||
seesaw = Seesaw(i2c)
|
||||
|
||||
# Create servo object
|
||||
pwm = PWMOut(seesaw, 17) # Servo 1 is on s.s. pin 17
|
||||
pwm.frequency = 50 # Servos like 50 Hz signals
|
||||
my_servo = servo.Servo(pwm) # Create my_servo with pwm signal
|
||||
|
||||
# LED for debugging
|
||||
led = DigitalInOut(board.D13)
|
||||
led.direction = Direction.OUTPUT
|
||||
|
||||
# two buttons!
|
||||
button_a = DigitalInOut(board.BUTTON_A)
|
||||
button_a.direction = Direction.INPUT
|
||||
button_a.pull = Pull.DOWN
|
||||
button_b = DigitalInOut(board.BUTTON_B)
|
||||
button_b.direction = Direction.INPUT
|
||||
button_b.pull = Pull.DOWN
|
||||
|
||||
# NeoPixels!
|
||||
pixels = neopixel.NeoPixel(board.NEOPIXEL, 10, brightness=1)
|
||||
pixels.fill((0,0,0))
|
||||
|
||||
#################### log file for logging mode!
|
||||
logfile = "/log.csv"
|
||||
# check that we could append if wanted to
|
||||
try:
|
||||
fp = None
|
||||
fp = open(logfile, "a")
|
||||
print("File system writable!")
|
||||
except:
|
||||
print("Not logging, trapeeze mode!")
|
||||
|
||||
# If we log, have some helper variables
|
||||
logging = False
|
||||
logpoints = 0
|
||||
outstr = ""
|
||||
|
||||
# When its time to release the trapeze
|
||||
release = False
|
||||
|
||||
while True:
|
||||
if button_a.value: # A pressed
|
||||
while button_a.value: # wait for release
|
||||
pass
|
||||
if fp: # start or stop logging
|
||||
logging = not logging
|
||||
print("Logging: ", logging)
|
||||
time.sleep(0.25)
|
||||
else:
|
||||
my_servo.angle = 180 # open
|
||||
|
||||
if button_b.value: # B pressed
|
||||
while button_b.value: # wait for release
|
||||
pass
|
||||
my_servo.angle = 0 # close
|
||||
|
||||
x, y, z = lis3dh.acceleration
|
||||
|
||||
# To keep from corrupting the filesys, take 25 readings at once
|
||||
if logging and fp:
|
||||
outstr += "%0.2F, %0.2F, %0.2F\n" % (x, y, z)
|
||||
logpoints += 1
|
||||
|
||||
if logpoints > 25:
|
||||
led.value = True
|
||||
#print("Writing: "+outstr)
|
||||
fp.write(outstr+"\n")
|
||||
fp.flush()
|
||||
led.value = False
|
||||
logpoints = 0
|
||||
else:
|
||||
# display some neopixel output!
|
||||
if z > 20:
|
||||
# MAXIMUM EFFORT!
|
||||
pixels.fill((0, 255, 0))
|
||||
if release:
|
||||
my_servo.angle = 180
|
||||
|
||||
elif z < 3 and y > 0: # means at the outer edge
|
||||
release = True
|
||||
# flash red when we peak
|
||||
pixels.fill((255, 0, 0))
|
||||
|
||||
else:
|
||||
pixels.fill((0,0,int(abs(z)*2)))
|
||||
|
||||
time.sleep(0.05)
|
||||
735
Crickits/flying_trapeze/log.csv
Normal file
735
Crickits/flying_trapeze/log.csv
Normal file
|
|
@ -0,0 +1,735 @@
|
|||
-2.57, 0.80, 9.31
|
||||
-2.80, 0.84, 9.27
|
||||
-2.91, 0.96, 9.31
|
||||
-2.80, 0.88, 8.92
|
||||
-2.91, 1.00, 9.15
|
||||
-2.57, 0.84, 9.31
|
||||
-2.57, 1.00, 9.31
|
||||
-2.76, 0.96, 9.19
|
||||
-2.95, 0.88, 9.12
|
||||
-2.91, 0.84, 9.38
|
||||
-2.72, 0.77, 9.27
|
||||
-2.68, 0.73, 9.27
|
||||
-2.53, 0.69, 9.42
|
||||
-2.87, 0.69, 9.27
|
||||
-3.18, 0.84, 9.19
|
||||
-2.76, 0.80, 9.27
|
||||
-2.64, 0.73, 9.23
|
||||
-2.72, 0.65, 9.31
|
||||
-2.68, 0.77, 9.23
|
||||
-2.95, 0.77, 9.27
|
||||
-2.60, 0.92, 9.35
|
||||
-2.60, 0.80, 9.27
|
||||
-2.80, 0.84, 9.23
|
||||
-2.83, 0.84, 9.27
|
||||
-2.91, 1.03, 9.19
|
||||
-2.87, 1.00, 9.27
|
||||
|
||||
-2.57, 0.80, 9.31
|
||||
-2.80, 0.84, 9.27
|
||||
-2.91, 0.96, 9.31
|
||||
-2.80, 0.88, 8.92
|
||||
-2.91, 1.00, 9.15
|
||||
-2.57, 0.84, 9.31
|
||||
-2.57, 1.00, 9.31
|
||||
-2.76, 0.96, 9.19
|
||||
-2.95, 0.88, 9.12
|
||||
-2.91, 0.84, 9.38
|
||||
-2.72, 0.77, 9.27
|
||||
-2.68, 0.73, 9.27
|
||||
-2.53, 0.69, 9.42
|
||||
-2.87, 0.69, 9.27
|
||||
-3.18, 0.84, 9.19
|
||||
-2.76, 0.80, 9.27
|
||||
-2.64, 0.73, 9.23
|
||||
-2.72, 0.65, 9.31
|
||||
-2.68, 0.77, 9.23
|
||||
-2.95, 0.77, 9.27
|
||||
-2.60, 0.92, 9.35
|
||||
-2.60, 0.80, 9.27
|
||||
-2.80, 0.84, 9.23
|
||||
-2.83, 0.84, 9.27
|
||||
-2.91, 1.03, 9.19
|
||||
-2.87, 1.00, 9.27
|
||||
-2.87, 0.96, 9.19
|
||||
-2.76, 1.07, 9.46
|
||||
-2.76, 0.88, 9.15
|
||||
-2.76, 1.03, 9.23
|
||||
-2.72, 0.80, 9.31
|
||||
-2.64, 1.00, 9.27
|
||||
-2.95, 0.92, 9.27
|
||||
-2.91, 0.92, 9.23
|
||||
-2.76, 1.00, 9.23
|
||||
-2.80, 0.88, 9.35
|
||||
-2.80, 0.88, 9.19
|
||||
-2.64, 0.50, 9.35
|
||||
-2.45, 1.11, 8.04
|
||||
-3.64, 0.88, 10.80
|
||||
-0.46, 0.42, 8.77
|
||||
-1.15, 1.19, 10.80
|
||||
-0.88, 0.92, 8.96
|
||||
-0.73, 0.61, 10.73
|
||||
-1.46, 0.27, 9.42
|
||||
-1.95, 1.00, 11.11
|
||||
0.27, -0.04, 10.00
|
||||
-2.07, 1.34, 10.73
|
||||
-0.73, 0.11, 10.73
|
||||
0.80, -0.19, 10.84
|
||||
0.08, 0.08, 11.11
|
||||
1.15, -0.50, 11.76
|
||||
|
||||
-2.57, 0.80, 9.31
|
||||
-2.80, 0.84, 9.27
|
||||
-2.91, 0.96, 9.31
|
||||
-2.80, 0.88, 8.92
|
||||
-2.91, 1.00, 9.15
|
||||
-2.57, 0.84, 9.31
|
||||
-2.57, 1.00, 9.31
|
||||
-2.76, 0.96, 9.19
|
||||
-2.95, 0.88, 9.12
|
||||
-2.91, 0.84, 9.38
|
||||
-2.72, 0.77, 9.27
|
||||
-2.68, 0.73, 9.27
|
||||
-2.53, 0.69, 9.42
|
||||
-2.87, 0.69, 9.27
|
||||
-3.18, 0.84, 9.19
|
||||
-2.76, 0.80, 9.27
|
||||
-2.64, 0.73, 9.23
|
||||
-2.72, 0.65, 9.31
|
||||
-2.68, 0.77, 9.23
|
||||
-2.95, 0.77, 9.27
|
||||
-2.60, 0.92, 9.35
|
||||
-2.60, 0.80, 9.27
|
||||
-2.80, 0.84, 9.23
|
||||
-2.83, 0.84, 9.27
|
||||
-2.91, 1.03, 9.19
|
||||
-2.87, 1.00, 9.27
|
||||
-2.87, 0.96, 9.19
|
||||
-2.76, 1.07, 9.46
|
||||
-2.76, 0.88, 9.15
|
||||
-2.76, 1.03, 9.23
|
||||
-2.72, 0.80, 9.31
|
||||
-2.64, 1.00, 9.27
|
||||
-2.95, 0.92, 9.27
|
||||
-2.91, 0.92, 9.23
|
||||
-2.76, 1.00, 9.23
|
||||
-2.80, 0.88, 9.35
|
||||
-2.80, 0.88, 9.19
|
||||
-2.64, 0.50, 9.35
|
||||
-2.45, 1.11, 8.04
|
||||
-3.64, 0.88, 10.80
|
||||
-0.46, 0.42, 8.77
|
||||
-1.15, 1.19, 10.80
|
||||
-0.88, 0.92, 8.96
|
||||
-0.73, 0.61, 10.73
|
||||
-1.46, 0.27, 9.42
|
||||
-1.95, 1.00, 11.11
|
||||
0.27, -0.04, 10.00
|
||||
-2.07, 1.34, 10.73
|
||||
-0.73, 0.11, 10.73
|
||||
0.80, -0.19, 10.84
|
||||
0.08, 0.08, 11.11
|
||||
1.15, -0.50, 11.76
|
||||
4.02, 0.00, 10.65
|
||||
2.30, -0.84, 8.96
|
||||
3.72, -0.34, 9.42
|
||||
1.57, -0.73, 8.89
|
||||
4.79, -0.08, 9.58
|
||||
2.07, -0.73, 8.27
|
||||
2.15, -0.15, 8.70
|
||||
4.41, -1.61, 8.73
|
||||
4.52, -0.73, 8.31
|
||||
4.86, -1.61, 7.62
|
||||
4.94, -0.57, 7.51
|
||||
4.75, -1.46, 7.70
|
||||
4.83, -0.92, 8.16
|
||||
3.98, -0.92, 7.01
|
||||
3.41, -0.92, 6.17
|
||||
3.06, -0.69, 5.98
|
||||
2.37, -0.69, 4.71
|
||||
1.65, -0.19, 5.82
|
||||
1.03, -0.08, 5.02
|
||||
-0.54, -0.57, 6.59
|
||||
-1.53, 0.46, 9.27
|
||||
-3.60, 1.26, 7.97
|
||||
-2.11, 0.31, 13.83
|
||||
-3.87, 1.84, 18.08
|
||||
-3.98, 1.34, 16.74
|
||||
-7.16, 1.99, 19.54
|
||||
|
||||
-2.57, 0.80, 9.31
|
||||
-2.80, 0.84, 9.27
|
||||
-2.91, 0.96, 9.31
|
||||
-2.80, 0.88, 8.92
|
||||
-2.91, 1.00, 9.15
|
||||
-2.57, 0.84, 9.31
|
||||
-2.57, 1.00, 9.31
|
||||
-2.76, 0.96, 9.19
|
||||
-2.95, 0.88, 9.12
|
||||
-2.91, 0.84, 9.38
|
||||
-2.72, 0.77, 9.27
|
||||
-2.68, 0.73, 9.27
|
||||
-2.53, 0.69, 9.42
|
||||
-2.87, 0.69, 9.27
|
||||
-3.18, 0.84, 9.19
|
||||
-2.76, 0.80, 9.27
|
||||
-2.64, 0.73, 9.23
|
||||
-2.72, 0.65, 9.31
|
||||
-2.68, 0.77, 9.23
|
||||
-2.95, 0.77, 9.27
|
||||
-2.60, 0.92, 9.35
|
||||
-2.60, 0.80, 9.27
|
||||
-2.80, 0.84, 9.23
|
||||
-2.83, 0.84, 9.27
|
||||
-2.91, 1.03, 9.19
|
||||
-2.87, 1.00, 9.27
|
||||
-2.87, 0.96, 9.19
|
||||
-2.76, 1.07, 9.46
|
||||
-2.76, 0.88, 9.15
|
||||
-2.76, 1.03, 9.23
|
||||
-2.72, 0.80, 9.31
|
||||
-2.64, 1.00, 9.27
|
||||
-2.95, 0.92, 9.27
|
||||
-2.91, 0.92, 9.23
|
||||
-2.76, 1.00, 9.23
|
||||
-2.80, 0.88, 9.35
|
||||
-2.80, 0.88, 9.19
|
||||
-2.64, 0.50, 9.35
|
||||
-2.45, 1.11, 8.04
|
||||
-3.64, 0.88, 10.80
|
||||
-0.46, 0.42, 8.77
|
||||
-1.15, 1.19, 10.80
|
||||
-0.88, 0.92, 8.96
|
||||
-0.73, 0.61, 10.73
|
||||
-1.46, 0.27, 9.42
|
||||
-1.95, 1.00, 11.11
|
||||
0.27, -0.04, 10.00
|
||||
-2.07, 1.34, 10.73
|
||||
-0.73, 0.11, 10.73
|
||||
0.80, -0.19, 10.84
|
||||
0.08, 0.08, 11.11
|
||||
1.15, -0.50, 11.76
|
||||
4.02, 0.00, 10.65
|
||||
2.30, -0.84, 8.96
|
||||
3.72, -0.34, 9.42
|
||||
1.57, -0.73, 8.89
|
||||
4.79, -0.08, 9.58
|
||||
2.07, -0.73, 8.27
|
||||
2.15, -0.15, 8.70
|
||||
4.41, -1.61, 8.73
|
||||
4.52, -0.73, 8.31
|
||||
4.86, -1.61, 7.62
|
||||
4.94, -0.57, 7.51
|
||||
4.75, -1.46, 7.70
|
||||
4.83, -0.92, 8.16
|
||||
3.98, -0.92, 7.01
|
||||
3.41, -0.92, 6.17
|
||||
3.06, -0.69, 5.98
|
||||
2.37, -0.69, 4.71
|
||||
1.65, -0.19, 5.82
|
||||
1.03, -0.08, 5.02
|
||||
-0.54, -0.57, 6.59
|
||||
-1.53, 0.46, 9.27
|
||||
-3.60, 1.26, 7.97
|
||||
-2.11, 0.31, 13.83
|
||||
-3.87, 1.84, 18.08
|
||||
-3.98, 1.34, 16.74
|
||||
-7.16, 1.99, 19.54
|
||||
-3.95, 1.38, 10.07
|
||||
-1.84, 0.57, 7.35
|
||||
-1.53, 0.54, 5.59
|
||||
-1.42, 0.23, 4.37
|
||||
-1.88, 0.19, 3.26
|
||||
-2.68, 0.31, 3.45
|
||||
-4.21, 0.96, 4.75
|
||||
-4.90, 0.92, 6.24
|
||||
-3.83, 1.19, 9.04
|
||||
-1.46, 1.11, 12.79
|
||||
-2.80, 1.84, 14.25
|
||||
-2.80, 2.87, 16.78
|
||||
-9.35, 2.64, 16.59
|
||||
-4.41, 1.61, 17.35
|
||||
-2.07, 1.65, 17.58
|
||||
-5.02, 1.76, 16.16
|
||||
-6.55, 1.80, 13.14
|
||||
-4.18, 0.77, 10.23
|
||||
-0.77, 1.15, 8.70
|
||||
-8.62, 2.80, 7.74
|
||||
5.78, -0.80, 2.60
|
||||
9.12, -3.33, 6.63
|
||||
9.08, -2.83, 6.63
|
||||
7.43, -2.18, 8.27
|
||||
6.21, -1.76, 7.55
|
||||
8.16, -2.30, 8.81
|
||||
|
||||
-2.57, 0.80, 9.31
|
||||
-2.80, 0.84, 9.27
|
||||
-2.91, 0.96, 9.31
|
||||
-2.80, 0.88, 8.92
|
||||
-2.91, 1.00, 9.15
|
||||
-2.57, 0.84, 9.31
|
||||
-2.57, 1.00, 9.31
|
||||
-2.76, 0.96, 9.19
|
||||
-2.95, 0.88, 9.12
|
||||
-2.91, 0.84, 9.38
|
||||
-2.72, 0.77, 9.27
|
||||
-2.68, 0.73, 9.27
|
||||
-2.53, 0.69, 9.42
|
||||
-2.87, 0.69, 9.27
|
||||
-3.18, 0.84, 9.19
|
||||
-2.76, 0.80, 9.27
|
||||
-2.64, 0.73, 9.23
|
||||
-2.72, 0.65, 9.31
|
||||
-2.68, 0.77, 9.23
|
||||
-2.95, 0.77, 9.27
|
||||
-2.60, 0.92, 9.35
|
||||
-2.60, 0.80, 9.27
|
||||
-2.80, 0.84, 9.23
|
||||
-2.83, 0.84, 9.27
|
||||
-2.91, 1.03, 9.19
|
||||
-2.87, 1.00, 9.27
|
||||
-2.87, 0.96, 9.19
|
||||
-2.76, 1.07, 9.46
|
||||
-2.76, 0.88, 9.15
|
||||
-2.76, 1.03, 9.23
|
||||
-2.72, 0.80, 9.31
|
||||
-2.64, 1.00, 9.27
|
||||
-2.95, 0.92, 9.27
|
||||
-2.91, 0.92, 9.23
|
||||
-2.76, 1.00, 9.23
|
||||
-2.80, 0.88, 9.35
|
||||
-2.80, 0.88, 9.19
|
||||
-2.64, 0.50, 9.35
|
||||
-2.45, 1.11, 8.04
|
||||
-3.64, 0.88, 10.80
|
||||
-0.46, 0.42, 8.77
|
||||
-1.15, 1.19, 10.80
|
||||
-0.88, 0.92, 8.96
|
||||
-0.73, 0.61, 10.73
|
||||
-1.46, 0.27, 9.42
|
||||
-1.95, 1.00, 11.11
|
||||
0.27, -0.04, 10.00
|
||||
-2.07, 1.34, 10.73
|
||||
-0.73, 0.11, 10.73
|
||||
0.80, -0.19, 10.84
|
||||
0.08, 0.08, 11.11
|
||||
1.15, -0.50, 11.76
|
||||
4.02, 0.00, 10.65
|
||||
2.30, -0.84, 8.96
|
||||
3.72, -0.34, 9.42
|
||||
1.57, -0.73, 8.89
|
||||
4.79, -0.08, 9.58
|
||||
2.07, -0.73, 8.27
|
||||
2.15, -0.15, 8.70
|
||||
4.41, -1.61, 8.73
|
||||
4.52, -0.73, 8.31
|
||||
4.86, -1.61, 7.62
|
||||
4.94, -0.57, 7.51
|
||||
4.75, -1.46, 7.70
|
||||
4.83, -0.92, 8.16
|
||||
3.98, -0.92, 7.01
|
||||
3.41, -0.92, 6.17
|
||||
3.06, -0.69, 5.98
|
||||
2.37, -0.69, 4.71
|
||||
1.65, -0.19, 5.82
|
||||
1.03, -0.08, 5.02
|
||||
-0.54, -0.57, 6.59
|
||||
-1.53, 0.46, 9.27
|
||||
-3.60, 1.26, 7.97
|
||||
-2.11, 0.31, 13.83
|
||||
-3.87, 1.84, 18.08
|
||||
-3.98, 1.34, 16.74
|
||||
-7.16, 1.99, 19.54
|
||||
-3.95, 1.38, 10.07
|
||||
-1.84, 0.57, 7.35
|
||||
-1.53, 0.54, 5.59
|
||||
-1.42, 0.23, 4.37
|
||||
-1.88, 0.19, 3.26
|
||||
-2.68, 0.31, 3.45
|
||||
-4.21, 0.96, 4.75
|
||||
-4.90, 0.92, 6.24
|
||||
-3.83, 1.19, 9.04
|
||||
-1.46, 1.11, 12.79
|
||||
-2.80, 1.84, 14.25
|
||||
-2.80, 2.87, 16.78
|
||||
-9.35, 2.64, 16.59
|
||||
-4.41, 1.61, 17.35
|
||||
-2.07, 1.65, 17.58
|
||||
-5.02, 1.76, 16.16
|
||||
-6.55, 1.80, 13.14
|
||||
-4.18, 0.77, 10.23
|
||||
-0.77, 1.15, 8.70
|
||||
-8.62, 2.80, 7.74
|
||||
5.78, -0.80, 2.60
|
||||
9.12, -3.33, 6.63
|
||||
9.08, -2.83, 6.63
|
||||
7.43, -2.18, 8.27
|
||||
6.21, -1.76, 7.55
|
||||
8.16, -2.30, 8.81
|
||||
2.22, -1.03, 4.98
|
||||
5.17, -1.03, 3.45
|
||||
1.23, -0.65, 3.60
|
||||
2.03, -0.08, 4.29
|
||||
1.61, -0.31, 4.60
|
||||
2.80, -0.38, 5.21
|
||||
1.84, -0.11, 6.24
|
||||
0.00, 0.00, 8.92
|
||||
-0.11, 0.57, 10.30
|
||||
-0.15, 0.73, 15.70
|
||||
-10.15, 2.95, 17.74
|
||||
-4.98, 1.65, 19.88
|
||||
-1.11, 1.72, 22.29
|
||||
-5.86, 2.11, 18.88
|
||||
-9.15, 2.68, 18.46
|
||||
-4.56, 1.99, 15.55
|
||||
-4.37, 1.38, 14.21
|
||||
-2.07, 0.92, 9.38
|
||||
-3.29, 0.77, 6.51
|
||||
-3.49, 0.84, 4.98
|
||||
-2.37, 0.46, 3.37
|
||||
-1.49, 0.11, 2.60
|
||||
-1.65, 0.15, 2.99
|
||||
-2.49, 0.57, 4.75
|
||||
-3.75, 1.15, 8.12
|
||||
-3.68, 1.30, 9.77
|
||||
|
||||
-2.57, 0.80, 9.31
|
||||
-2.80, 0.84, 9.27
|
||||
-2.91, 0.96, 9.31
|
||||
-2.80, 0.88, 8.92
|
||||
-2.91, 1.00, 9.15
|
||||
-2.57, 0.84, 9.31
|
||||
-2.57, 1.00, 9.31
|
||||
-2.76, 0.96, 9.19
|
||||
-2.95, 0.88, 9.12
|
||||
-2.91, 0.84, 9.38
|
||||
-2.72, 0.77, 9.27
|
||||
-2.68, 0.73, 9.27
|
||||
-2.53, 0.69, 9.42
|
||||
-2.87, 0.69, 9.27
|
||||
-3.18, 0.84, 9.19
|
||||
-2.76, 0.80, 9.27
|
||||
-2.64, 0.73, 9.23
|
||||
-2.72, 0.65, 9.31
|
||||
-2.68, 0.77, 9.23
|
||||
-2.95, 0.77, 9.27
|
||||
-2.60, 0.92, 9.35
|
||||
-2.60, 0.80, 9.27
|
||||
-2.80, 0.84, 9.23
|
||||
-2.83, 0.84, 9.27
|
||||
-2.91, 1.03, 9.19
|
||||
-2.87, 1.00, 9.27
|
||||
-2.87, 0.96, 9.19
|
||||
-2.76, 1.07, 9.46
|
||||
-2.76, 0.88, 9.15
|
||||
-2.76, 1.03, 9.23
|
||||
-2.72, 0.80, 9.31
|
||||
-2.64, 1.00, 9.27
|
||||
-2.95, 0.92, 9.27
|
||||
-2.91, 0.92, 9.23
|
||||
-2.76, 1.00, 9.23
|
||||
-2.80, 0.88, 9.35
|
||||
-2.80, 0.88, 9.19
|
||||
-2.64, 0.50, 9.35
|
||||
-2.45, 1.11, 8.04
|
||||
-3.64, 0.88, 10.80
|
||||
-0.46, 0.42, 8.77
|
||||
-1.15, 1.19, 10.80
|
||||
-0.88, 0.92, 8.96
|
||||
-0.73, 0.61, 10.73
|
||||
-1.46, 0.27, 9.42
|
||||
-1.95, 1.00, 11.11
|
||||
0.27, -0.04, 10.00
|
||||
-2.07, 1.34, 10.73
|
||||
-0.73, 0.11, 10.73
|
||||
0.80, -0.19, 10.84
|
||||
0.08, 0.08, 11.11
|
||||
1.15, -0.50, 11.76
|
||||
4.02, 0.00, 10.65
|
||||
2.30, -0.84, 8.96
|
||||
3.72, -0.34, 9.42
|
||||
1.57, -0.73, 8.89
|
||||
4.79, -0.08, 9.58
|
||||
2.07, -0.73, 8.27
|
||||
2.15, -0.15, 8.70
|
||||
4.41, -1.61, 8.73
|
||||
4.52, -0.73, 8.31
|
||||
4.86, -1.61, 7.62
|
||||
4.94, -0.57, 7.51
|
||||
4.75, -1.46, 7.70
|
||||
4.83, -0.92, 8.16
|
||||
3.98, -0.92, 7.01
|
||||
3.41, -0.92, 6.17
|
||||
3.06, -0.69, 5.98
|
||||
2.37, -0.69, 4.71
|
||||
1.65, -0.19, 5.82
|
||||
1.03, -0.08, 5.02
|
||||
-0.54, -0.57, 6.59
|
||||
-1.53, 0.46, 9.27
|
||||
-3.60, 1.26, 7.97
|
||||
-2.11, 0.31, 13.83
|
||||
-3.87, 1.84, 18.08
|
||||
-3.98, 1.34, 16.74
|
||||
-7.16, 1.99, 19.54
|
||||
-3.95, 1.38, 10.07
|
||||
-1.84, 0.57, 7.35
|
||||
-1.53, 0.54, 5.59
|
||||
-1.42, 0.23, 4.37
|
||||
-1.88, 0.19, 3.26
|
||||
-2.68, 0.31, 3.45
|
||||
-4.21, 0.96, 4.75
|
||||
-4.90, 0.92, 6.24
|
||||
-3.83, 1.19, 9.04
|
||||
-1.46, 1.11, 12.79
|
||||
-2.80, 1.84, 14.25
|
||||
-2.80, 2.87, 16.78
|
||||
-9.35, 2.64, 16.59
|
||||
-4.41, 1.61, 17.35
|
||||
-2.07, 1.65, 17.58
|
||||
-5.02, 1.76, 16.16
|
||||
-6.55, 1.80, 13.14
|
||||
-4.18, 0.77, 10.23
|
||||
-0.77, 1.15, 8.70
|
||||
-8.62, 2.80, 7.74
|
||||
5.78, -0.80, 2.60
|
||||
9.12, -3.33, 6.63
|
||||
9.08, -2.83, 6.63
|
||||
7.43, -2.18, 8.27
|
||||
6.21, -1.76, 7.55
|
||||
8.16, -2.30, 8.81
|
||||
2.22, -1.03, 4.98
|
||||
5.17, -1.03, 3.45
|
||||
1.23, -0.65, 3.60
|
||||
2.03, -0.08, 4.29
|
||||
1.61, -0.31, 4.60
|
||||
2.80, -0.38, 5.21
|
||||
1.84, -0.11, 6.24
|
||||
0.00, 0.00, 8.92
|
||||
-0.11, 0.57, 10.30
|
||||
-0.15, 0.73, 15.70
|
||||
-10.15, 2.95, 17.74
|
||||
-4.98, 1.65, 19.88
|
||||
-1.11, 1.72, 22.29
|
||||
-5.86, 2.11, 18.88
|
||||
-9.15, 2.68, 18.46
|
||||
-4.56, 1.99, 15.55
|
||||
-4.37, 1.38, 14.21
|
||||
-2.07, 0.92, 9.38
|
||||
-3.29, 0.77, 6.51
|
||||
-3.49, 0.84, 4.98
|
||||
-2.37, 0.46, 3.37
|
||||
-1.49, 0.11, 2.60
|
||||
-1.65, 0.15, 2.99
|
||||
-2.49, 0.57, 4.75
|
||||
-3.75, 1.15, 8.12
|
||||
-3.68, 1.30, 9.77
|
||||
-4.79, 1.95, 18.23
|
||||
-5.09, 1.72, 16.43
|
||||
-4.90, 1.34, 14.06
|
||||
-3.10, 0.69, 10.84
|
||||
-3.45, 2.91, 8.20
|
||||
7.16, 1.84, 9.84
|
||||
2.72, -3.22, 5.86
|
||||
10.30, -1.65, 7.05
|
||||
6.47, -1.80, 7.81
|
||||
6.24, -1.42, 8.08
|
||||
6.13, -1.23, 8.31
|
||||
4.63, -1.19, 7.39
|
||||
6.93, -0.80, 6.32
|
||||
5.71, -1.26, 6.93
|
||||
4.79, -1.23, 6.55
|
||||
3.14, -0.69, 5.25
|
||||
2.95, -0.84, 4.44
|
||||
1.11, 0.08, 4.21
|
||||
1.92, -0.38, 4.67
|
||||
0.88, -0.04, 5.25
|
||||
0.31, -0.23, 6.93
|
||||
-3.75, 1.92, 8.24
|
||||
-3.91, 0.23, 10.30
|
||||
-6.67, 2.15, 17.66
|
||||
-2.76, 1.72, 19.61
|
||||
-2.26, 1.92, 19.88
|
||||
|
||||
-2.57, 0.80, 9.31
|
||||
-2.80, 0.84, 9.27
|
||||
-2.91, 0.96, 9.31
|
||||
-2.80, 0.88, 8.92
|
||||
-2.91, 1.00, 9.15
|
||||
-2.57, 0.84, 9.31
|
||||
-2.57, 1.00, 9.31
|
||||
-2.76, 0.96, 9.19
|
||||
-2.95, 0.88, 9.12
|
||||
-2.91, 0.84, 9.38
|
||||
-2.72, 0.77, 9.27
|
||||
-2.68, 0.73, 9.27
|
||||
-2.53, 0.69, 9.42
|
||||
-2.87, 0.69, 9.27
|
||||
-3.18, 0.84, 9.19
|
||||
-2.76, 0.80, 9.27
|
||||
-2.64, 0.73, 9.23
|
||||
-2.72, 0.65, 9.31
|
||||
-2.68, 0.77, 9.23
|
||||
-2.95, 0.77, 9.27
|
||||
-2.60, 0.92, 9.35
|
||||
-2.60, 0.80, 9.27
|
||||
-2.80, 0.84, 9.23
|
||||
-2.83, 0.84, 9.27
|
||||
-2.91, 1.03, 9.19
|
||||
-2.87, 1.00, 9.27
|
||||
-2.87, 0.96, 9.19
|
||||
-2.76, 1.07, 9.46
|
||||
-2.76, 0.88, 9.15
|
||||
-2.76, 1.03, 9.23
|
||||
-2.72, 0.80, 9.31
|
||||
-2.64, 1.00, 9.27
|
||||
-2.95, 0.92, 9.27
|
||||
-2.91, 0.92, 9.23
|
||||
-2.76, 1.00, 9.23
|
||||
-2.80, 0.88, 9.35
|
||||
-2.80, 0.88, 9.19
|
||||
-2.64, 0.50, 9.35
|
||||
-2.45, 1.11, 8.04
|
||||
-3.64, 0.88, 10.80
|
||||
-0.46, 0.42, 8.77
|
||||
-1.15, 1.19, 10.80
|
||||
-0.88, 0.92, 8.96
|
||||
-0.73, 0.61, 10.73
|
||||
-1.46, 0.27, 9.42
|
||||
-1.95, 1.00, 11.11
|
||||
0.27, -0.04, 10.00
|
||||
-2.07, 1.34, 10.73
|
||||
-0.73, 0.11, 10.73
|
||||
0.80, -0.19, 10.84
|
||||
0.08, 0.08, 11.11
|
||||
1.15, -0.50, 11.76
|
||||
4.02, 0.00, 10.65
|
||||
2.30, -0.84, 8.96
|
||||
3.72, -0.34, 9.42
|
||||
1.57, -0.73, 8.89
|
||||
4.79, -0.08, 9.58
|
||||
2.07, -0.73, 8.27
|
||||
2.15, -0.15, 8.70
|
||||
4.41, -1.61, 8.73
|
||||
4.52, -0.73, 8.31
|
||||
4.86, -1.61, 7.62
|
||||
4.94, -0.57, 7.51
|
||||
4.75, -1.46, 7.70
|
||||
4.83, -0.92, 8.16
|
||||
3.98, -0.92, 7.01
|
||||
3.41, -0.92, 6.17
|
||||
3.06, -0.69, 5.98
|
||||
2.37, -0.69, 4.71
|
||||
1.65, -0.19, 5.82
|
||||
1.03, -0.08, 5.02
|
||||
-0.54, -0.57, 6.59
|
||||
-1.53, 0.46, 9.27
|
||||
-3.60, 1.26, 7.97
|
||||
-2.11, 0.31, 13.83
|
||||
-3.87, 1.84, 18.08
|
||||
-3.98, 1.34, 16.74
|
||||
-7.16, 1.99, 19.54
|
||||
-3.95, 1.38, 10.07
|
||||
-1.84, 0.57, 7.35
|
||||
-1.53, 0.54, 5.59
|
||||
-1.42, 0.23, 4.37
|
||||
-1.88, 0.19, 3.26
|
||||
-2.68, 0.31, 3.45
|
||||
-4.21, 0.96, 4.75
|
||||
-4.90, 0.92, 6.24
|
||||
-3.83, 1.19, 9.04
|
||||
-1.46, 1.11, 12.79
|
||||
-2.80, 1.84, 14.25
|
||||
-2.80, 2.87, 16.78
|
||||
-9.35, 2.64, 16.59
|
||||
-4.41, 1.61, 17.35
|
||||
-2.07, 1.65, 17.58
|
||||
-5.02, 1.76, 16.16
|
||||
-6.55, 1.80, 13.14
|
||||
-4.18, 0.77, 10.23
|
||||
-0.77, 1.15, 8.70
|
||||
-8.62, 2.80, 7.74
|
||||
5.78, -0.80, 2.60
|
||||
9.12, -3.33, 6.63
|
||||
9.08, -2.83, 6.63
|
||||
7.43, -2.18, 8.27
|
||||
6.21, -1.76, 7.55
|
||||
8.16, -2.30, 8.81
|
||||
2.22, -1.03, 4.98
|
||||
5.17, -1.03, 3.45
|
||||
1.23, -0.65, 3.60
|
||||
2.03, -0.08, 4.29
|
||||
1.61, -0.31, 4.60
|
||||
2.80, -0.38, 5.21
|
||||
1.84, -0.11, 6.24
|
||||
0.00, 0.00, 8.92
|
||||
-0.11, 0.57, 10.30
|
||||
-0.15, 0.73, 15.70
|
||||
-10.15, 2.95, 17.74
|
||||
-4.98, 1.65, 19.88
|
||||
-1.11, 1.72, 22.29
|
||||
-5.86, 2.11, 18.88
|
||||
-9.15, 2.68, 18.46
|
||||
-4.56, 1.99, 15.55
|
||||
-4.37, 1.38, 14.21
|
||||
-2.07, 0.92, 9.38
|
||||
-3.29, 0.77, 6.51
|
||||
-3.49, 0.84, 4.98
|
||||
-2.37, 0.46, 3.37
|
||||
-1.49, 0.11, 2.60
|
||||
-1.65, 0.15, 2.99
|
||||
-2.49, 0.57, 4.75
|
||||
-3.75, 1.15, 8.12
|
||||
-3.68, 1.30, 9.77
|
||||
-4.79, 1.95, 18.23
|
||||
-5.09, 1.72, 16.43
|
||||
-4.90, 1.34, 14.06
|
||||
-3.10, 0.69, 10.84
|
||||
-3.45, 2.91, 8.20
|
||||
7.16, 1.84, 9.84
|
||||
2.72, -3.22, 5.86
|
||||
10.30, -1.65, 7.05
|
||||
6.47, -1.80, 7.81
|
||||
6.24, -1.42, 8.08
|
||||
6.13, -1.23, 8.31
|
||||
4.63, -1.19, 7.39
|
||||
6.93, -0.80, 6.32
|
||||
5.71, -1.26, 6.93
|
||||
4.79, -1.23, 6.55
|
||||
3.14, -0.69, 5.25
|
||||
2.95, -0.84, 4.44
|
||||
1.11, 0.08, 4.21
|
||||
1.92, -0.38, 4.67
|
||||
0.88, -0.04, 5.25
|
||||
0.31, -0.23, 6.93
|
||||
-3.75, 1.92, 8.24
|
||||
-3.91, 0.23, 10.30
|
||||
-6.67, 2.15, 17.66
|
||||
-2.76, 1.72, 19.61
|
||||
-2.26, 1.92, 19.88
|
||||
-3.03, 0.69, 6.21
|
||||
-2.37, 0.57, 4.98
|
||||
-1.23, 0.19, 3.91
|
||||
-0.96, 0.15, 2.72
|
||||
-1.46, 0.31, 3.52
|
||||
-3.14, 0.54, 5.78
|
||||
-4.83, 1.26, 8.27
|
||||
-4.56, 1.26, 9.81
|
||||
-3.33, 1.23, 13.60
|
||||
-3.87, 1.84, 16.39
|
||||
-7.05, 2.30, 17.85
|
||||
-7.97, 2.34, 17.96
|
||||
-4.56, 1.95, 17.77
|
||||
-3.37, 1.53, 17.16
|
||||
-4.83, 1.61, 15.02
|
||||
-4.52, 1.19, 11.80
|
||||
-3.03, 0.92, 9.96
|
||||
-6.21, 2.41, 1.61
|
||||
2.95, -1.84, 16.01
|
||||
6.74, -1.30, 7.74
|
||||
8.08, -1.57, 7.66
|
||||
6.32, -0.54, 7.39
|
||||
6.01, -1.26, 7.70
|
||||
4.79, -1.00, 8.04
|
||||
5.44, -0.80, 6.82
|
||||
3.87, -1.34, 8.39
|
||||
|
||||
|
72
Crickits/ghost_slime/code.py
Normal file
72
Crickits/ghost_slime/code.py
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
from digitalio import DigitalInOut, Direction, Pull
|
||||
from adafruit_seesaw.seesaw import Seesaw
|
||||
from adafruit_seesaw.analoginput import AnalogInput
|
||||
from adafruit_seesaw.pwmout import PWMOut
|
||||
from adafruit_motor import motor
|
||||
from busio import I2C
|
||||
import neopixel
|
||||
import audioio
|
||||
import board
|
||||
import time
|
||||
|
||||
# Create seesaw object
|
||||
i2c = I2C(board.SCL, board.SDA)
|
||||
seesaw = Seesaw(i2c)
|
||||
|
||||
# built in CPX button A
|
||||
button = DigitalInOut(board.BUTTON_A)
|
||||
button.direction = Direction.INPUT
|
||||
button.pull = Pull.DOWN
|
||||
|
||||
# NeoPixels
|
||||
pixels = neopixel.NeoPixel(board.A1, 10, brightness=0)
|
||||
pixels.fill((0,0,250))
|
||||
|
||||
# Analog reading from Signal #1 (ss. #2)
|
||||
foot_pedal = AnalogInput(seesaw, 2)
|
||||
|
||||
# Create one motor on seesaw PWM pins 22 & 23
|
||||
motor_a = motor.DCMotor(PWMOut(seesaw, 22), PWMOut(seesaw, 23))
|
||||
motor_a.throttle = 0
|
||||
|
||||
def map_range(x, in_min, in_max, out_min, out_max):
|
||||
# Maps a number from one range to another.
|
||||
mapped = (x-in_min) * (out_max - out_min) / (in_max-in_min) + out_min
|
||||
if out_min <= out_max:
|
||||
return max(min(mapped, out_max), out_min)
|
||||
return min(max(mapped, out_max), out_min)
|
||||
|
||||
# Get the audio file ready
|
||||
wavfile = "unchained.wav"
|
||||
f = open(wavfile, "rb")
|
||||
wav = audioio.WaveFile(f)
|
||||
a = audioio.AudioOut(board.A0)
|
||||
|
||||
time_to_play = 0 # when to start playing
|
||||
played = False # have we played audio already? only play once!
|
||||
while True:
|
||||
# Foot pedal ranges from about 700 (unpressed) to 50 (pressed)
|
||||
# make that change the speed of the motor from 0 (stopped) to 0.5 (half)
|
||||
press = foot_pedal.value
|
||||
speed = map_range(press, 700, 50, 0, 0.5)
|
||||
print("%d -> %0.3f" % (press, speed))
|
||||
motor_a.throttle = speed
|
||||
|
||||
if not time_to_play and speed > 0.1:
|
||||
print("Start audio in 3 seconds")
|
||||
time_to_play = time.monotonic() + 3
|
||||
elif time_to_play and time.monotonic() > time_to_play and not played:
|
||||
print("Playing audio")
|
||||
a.play(wav)
|
||||
played = True
|
||||
|
||||
# turn on/off blue LEDs
|
||||
if button.value:
|
||||
if pixels.brightness < 0.1:
|
||||
pixels.brightness = 1
|
||||
else:
|
||||
pixels.brightness = 0
|
||||
time.sleep(0.5)
|
||||
|
||||
# loop delay
|
||||
time.sleep(0.1)
|
||||
BIN
Crickits/ghost_slime/ghosty.fzz
Normal file
BIN
Crickits/ghost_slime/ghosty.fzz
Normal file
Binary file not shown.
44
Crickits/trash_panda/code.py
Normal file
44
Crickits/trash_panda/code.py
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
from digitalio import DigitalInOut, Direction, Pull
|
||||
from adafruit_seesaw.seesaw import Seesaw
|
||||
from adafruit_seesaw.pwmout import PWMOut
|
||||
from adafruit_motor import servo
|
||||
from busio import I2C
|
||||
import board
|
||||
import time
|
||||
|
||||
|
||||
# Create seesaw object
|
||||
i2c = I2C(board.SCL, board.SDA)
|
||||
seesaw = Seesaw(i2c)
|
||||
|
||||
led = DigitalInOut(board.D13)
|
||||
led.direction = Direction.OUTPUT
|
||||
|
||||
# Create servos list
|
||||
servos = []
|
||||
for ss_pin in (17, 16, 15, 14):
|
||||
pwm = PWMOut(seesaw, ss_pin)
|
||||
pwm.frequency = 50
|
||||
_servo = servo.Servo(pwm, min_pulse=600, max_pulse=2500)
|
||||
_servo.angle = 90 # starting angle, middle
|
||||
servos.append(_servo)
|
||||
|
||||
print("Its TRASH PANDA TIME!")
|
||||
|
||||
while True:
|
||||
print("tick")
|
||||
led.value = True
|
||||
servos[0].angle = 0
|
||||
time.sleep(0.5)
|
||||
servos[1].angle = 180
|
||||
time.sleep(0.5)
|
||||
servos[2].angle = 0
|
||||
time.sleep(0.5)
|
||||
print("tock")
|
||||
led.value = False
|
||||
servos[0].angle = 180
|
||||
time.sleep(0.5)
|
||||
servos[1].angle = 0
|
||||
time.sleep(0.5)
|
||||
servos[2].angle = 180
|
||||
time.sleep(0.5)
|
||||
10
Crickits/yanny_or_laurel/boot.py
Normal file
10
Crickits/yanny_or_laurel/boot.py
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
import digitalio
|
||||
import board
|
||||
import storage
|
||||
|
||||
switch = digitalio.DigitalInOut(board.D7) # For Circuit Playground Express
|
||||
switch.direction = digitalio.Direction.INPUT
|
||||
switch.pull = digitalio.Pull.UP
|
||||
|
||||
# If the switch pin is connected to ground CircuitPython can write to the drive
|
||||
storage.remount("/", switch.value)
|
||||
112
Crickits/yanny_or_laurel/code.py
Normal file
112
Crickits/yanny_or_laurel/code.py
Normal file
|
|
@ -0,0 +1,112 @@
|
|||
# CircuitPython 3.0 CRICKIT demo
|
||||
from adafruit_seesaw.seesaw import Seesaw
|
||||
from adafruit_seesaw.pwmout import PWMOut
|
||||
from adafruit_motor import servo
|
||||
from busio import I2C
|
||||
import audioio
|
||||
import microcontroller
|
||||
import board
|
||||
import time
|
||||
|
||||
i2c = I2C(board.SCL, board.SDA)
|
||||
ss = Seesaw(i2c)
|
||||
|
||||
print("Yanny or Laurel data logging!")
|
||||
|
||||
LOOKATPERSON = 90
|
||||
LOOKLEFT = 60
|
||||
LOOKRIGHT = 120
|
||||
|
||||
#################### 1 Servo
|
||||
pwm = PWMOut(ss, 17)
|
||||
pwm.frequency = 50
|
||||
myservo = servo.Servo(pwm)
|
||||
myservo.angle = LOOKATPERSON # introduce yourself
|
||||
|
||||
#################### 2 buttons w/2 LEDs
|
||||
BUTTON_1 = 2
|
||||
BUTTON_2 = 3
|
||||
LED_1 = 8
|
||||
LED_2 = 9
|
||||
|
||||
# Two buttons are pullups, connect to ground to activate
|
||||
ss.pin_mode(BUTTON_1, ss.INPUT_PULLUP)
|
||||
ss.pin_mode(BUTTON_2, ss.INPUT_PULLUP)
|
||||
# Two LEDs are outputs, on by default
|
||||
ss.pin_mode(LED_1, ss.OUTPUT)
|
||||
ss.pin_mode(LED_2, ss.OUTPUT)
|
||||
ss.digital_write(LED_1, True)
|
||||
ss.digital_write(LED_2, True)
|
||||
|
||||
#################### log files
|
||||
logfile = "/log.csv"
|
||||
# check that we could append if wanted to
|
||||
try:
|
||||
fp = open(logfile, "a")
|
||||
fp.close
|
||||
except:
|
||||
print("File system not writable, halting")
|
||||
while True:
|
||||
pass
|
||||
|
||||
#################### Audio files
|
||||
wavfile = "yanny.wav"
|
||||
f = open(wavfile, "rb")
|
||||
wav = audioio.WaveFile(f)
|
||||
a = audioio.AudioOut(board.A0)
|
||||
a.play(wav)
|
||||
t = time.monotonic()
|
||||
|
||||
# Wait
|
||||
while time.monotonic() - t < 7.5:
|
||||
pass
|
||||
|
||||
while time.monotonic() - t < 9.5:
|
||||
myservo.angle = LOOKLEFT
|
||||
ss.digital_write(LED_1, True)
|
||||
ss.digital_write(LED_2, False)
|
||||
time.sleep(0.5)
|
||||
myservo.angle = LOOKRIGHT
|
||||
ss.digital_write(LED_1, False)
|
||||
ss.digital_write(LED_2, True)
|
||||
time.sleep(0.5)
|
||||
|
||||
myservo.angle = LOOKATPERSON
|
||||
|
||||
# reset LEDs
|
||||
ss.digital_write(LED_1, False)
|
||||
ss.digital_write(LED_2, False)
|
||||
|
||||
selection = None
|
||||
# wait until
|
||||
while not selection:
|
||||
if not ss.digital_read(BUTTON_1):
|
||||
selection = "Yanny"
|
||||
ss.digital_write(LED_1, True)
|
||||
myservo.angle = LOOKLEFT
|
||||
break
|
||||
if not ss.digital_read(BUTTON_2):
|
||||
selection = "Laurel"
|
||||
ss.digital_write(LED_2, True)
|
||||
myservo.angle = LOOKRIGHT
|
||||
break
|
||||
# if we havent selected, wait until they do!
|
||||
if a.playing and time.monotonic() - t > 15.5:
|
||||
a.pause()
|
||||
|
||||
# now we have a selection!
|
||||
with open(logfile, "a") as fp:
|
||||
print("Writing!"+selection+", 1\n")
|
||||
fp.write(selection+", 1\n")
|
||||
fp.flush()
|
||||
print("Written")
|
||||
|
||||
# OK play the rest of the music
|
||||
a.resume()
|
||||
while a.playing:
|
||||
pass
|
||||
|
||||
ss.digital_write(LED_1, False)
|
||||
ss.digital_write(LED_2, False)
|
||||
|
||||
microcontroller.reset()
|
||||
BIN
Crickits/yanny_or_laurel/yanny.wav
Normal file
BIN
Crickits/yanny_or_laurel/yanny.wav
Normal file
Binary file not shown.
87
Crickits/yayayay_flier/code.py
Normal file
87
Crickits/yayayay_flier/code.py
Normal file
|
|
@ -0,0 +1,87 @@
|
|||
import gc
|
||||
import pulseio
|
||||
gc.collect()
|
||||
import adafruit_irremote
|
||||
gc.collect()
|
||||
from adafruit_motor import motor
|
||||
gc.collect()
|
||||
from adafruit_seesaw.seesaw import Seesaw
|
||||
gc.collect()
|
||||
from adafruit_seesaw.pwmout import PWMOut
|
||||
gc.collect()
|
||||
import neopixel
|
||||
gc.collect()
|
||||
import audioio
|
||||
gc.collect()
|
||||
from busio import I2C
|
||||
import board
|
||||
import time
|
||||
|
||||
|
||||
print("Blimp!")
|
||||
|
||||
# Create Infrared reader
|
||||
pulsein = pulseio.PulseIn(board.REMOTEIN, maxlen=100, idle_state=True)
|
||||
decoder = adafruit_irremote.GenericDecode()
|
||||
REMOTE_FORWARD = [255, 2, 175, 80]
|
||||
REMOTE_BACKWARD = [255, 2, 239, 16]
|
||||
REMOTE_PAUSE = [255, 2, 127, 128]
|
||||
|
||||
# Create seesaw object
|
||||
seesaw = Seesaw(I2C(board.SCL, board.SDA))
|
||||
|
||||
# Create one motor on seesaw PWM pins 22 & 23
|
||||
motor_a = motor.DCMotor(PWMOut(seesaw, 22), PWMOut(seesaw, 23))
|
||||
motor_a.throttle = 0
|
||||
|
||||
# Neopix!@
|
||||
pixels = neopixel.NeoPixel(board.NEOPIXEL, 10)
|
||||
|
||||
# audio file
|
||||
a = audioio.AudioOut(board.A0)
|
||||
def play_audio(wavfile):
|
||||
f = open(wavfile, "rb")
|
||||
wav = audioio.WaveFile(f)
|
||||
a.play(wav)
|
||||
while a.playing:
|
||||
pass
|
||||
f.close()
|
||||
gc.collect()
|
||||
|
||||
play_audio("overview.wav")
|
||||
t = time.monotonic()
|
||||
|
||||
while True:
|
||||
command = None # assume no remote commands came in
|
||||
if len(pulsein) > 25: # check in any IR data came in
|
||||
pulses = decoder.read_pulses(pulsein)
|
||||
try:
|
||||
code = decoder.decode_bits(pulses, debug=False)
|
||||
if code in (REMOTE_FORWARD, REMOTE_BACKWARD, REMOTE_PAUSE):
|
||||
# we only listen to a few different codes
|
||||
command = code
|
||||
else:
|
||||
continue
|
||||
# on any failure, lets just restart
|
||||
except:
|
||||
continue
|
||||
|
||||
if command:
|
||||
if code == REMOTE_FORWARD:
|
||||
play_audio("fan_forward.wav")
|
||||
motor_a.throttle = 1 # full speed forward
|
||||
pixels.fill((255,0,0))
|
||||
elif code == REMOTE_BACKWARD:
|
||||
play_audio("fan_backward.wav")
|
||||
motor_a.throttle = -1 # full speed backward
|
||||
pixels.fill((0,0,255))
|
||||
elif code == REMOTE_PAUSE:
|
||||
motor_a.throttle = 0 # stop motor
|
||||
play_audio("fan_stopped.wav")
|
||||
pixels.fill((0,0,0))
|
||||
time.sleep(0.5)
|
||||
|
||||
# play yayayay every 3 seconds
|
||||
if (time.monotonic() - t > 3) and motor_a.throttle != 0:
|
||||
t = time.monotonic()
|
||||
play_audio("yayyayyay.wav")
|
||||
BIN
Crickits/yayayay_flier/fan_backward.wav
Normal file
BIN
Crickits/yayayay_flier/fan_backward.wav
Normal file
Binary file not shown.
BIN
Crickits/yayayay_flier/fan_forward.wav
Normal file
BIN
Crickits/yayayay_flier/fan_forward.wav
Normal file
Binary file not shown.
BIN
Crickits/yayayay_flier/fan_stopped.wav
Normal file
BIN
Crickits/yayayay_flier/fan_stopped.wav
Normal file
Binary file not shown.
BIN
Crickits/yayayay_flier/overview.wav
Normal file
BIN
Crickits/yayayay_flier/overview.wav
Normal file
Binary file not shown.
BIN
Crickits/yayayay_flier/yayyayyay.wav
Normal file
BIN
Crickits/yayayay_flier/yayyayyay.wav
Normal file
Binary file not shown.
|
|
@ -99,3 +99,4 @@ while True:
|
|||
touch_A2_state = "ready"
|
||||
if touch_A2.value and touch_A2_state == "ready":
|
||||
next(brightness)
|
||||
touch_A2_state = None
|
||||
|
|
|
|||
21
Humidity_Alarm/LICENSE
Normal file
21
Humidity_Alarm/LICENSE
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2017 Dave Astels
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
100
Humidity_Alarm/humidity_alarm.ino
Normal file
100
Humidity_Alarm/humidity_alarm.ino
Normal file
|
|
@ -0,0 +1,100 @@
|
|||
// Humidity Monitor
|
||||
// Copyright (C) 2017 Dave Astels
|
||||
// Released until the MIT license
|
||||
//
|
||||
// The trinket is controlled by an external Power Timer Breakout
|
||||
// (https://www.adafruit.com/product/3435)
|
||||
// 1. Every however often, the timer will power up the trinket which will run
|
||||
// this file.
|
||||
// 2. Relative humidity is checked
|
||||
// - if it's within range, the trinket tells the timer to shut it down and start
|
||||
// the timing cycle
|
||||
// - if it's out of range, it beeps & flashes the neopixel for 2 seconds, then
|
||||
// sleeps for 10 seconds, then goes to 2
|
||||
|
||||
#include "Adafruit_Si7021.h"
|
||||
#include <Adafruit_DotStar.h>
|
||||
#include <SPI.h>
|
||||
|
||||
const unsigned long falling_tones[] = { 2000, 1980, 1960, 1940, 1920, 1900, 1880, 1860, 1840, 1820, 1800, 1780, 1760, 1740, 1720, 1700, 1680, 1660, 1640, 1620 };
|
||||
const unsigned long rising_tones[] = { 2000, 2020, 2040, 2060, 2080, 3000, 3020, 3040, 3060, 3080, 4000, 4020, 4040, 4060, 4080, 5000, 5020, 5040, 5060, 5080 };
|
||||
|
||||
const int dotstar_data_pin = 7;
|
||||
const int dotstar_clock_pin = 8;
|
||||
const int sound_pin = 3;
|
||||
const int sleep_pin = 4;
|
||||
|
||||
const int target_humidity = 61.0;
|
||||
const unsigned long alert_interval = 20000;
|
||||
const unsigned long alert_duration = 500;
|
||||
const unsigned long comparison_delay = alert_interval - alert_duration;
|
||||
const unsigned long number_of_freq_steps = 20;
|
||||
const unsigned long alert_freq_step_time = alert_duration / number_of_freq_steps;
|
||||
|
||||
Adafruit_Si7021 sensor = Adafruit_Si7021();
|
||||
//Adafruit_DotStar strip = Adafruit_DotStar(1, DOTSTAR_BRG);
|
||||
|
||||
//--------------------------------------------------------------------------------
|
||||
// Sound the alert.
|
||||
|
||||
void chirp(boolean direction)
|
||||
{
|
||||
const unsigned long *freqs = direction ? rising_tones : falling_tones;
|
||||
for (int i = 0; i < number_of_freq_steps; i++) {
|
||||
tone(sound_pin, freqs[i]);
|
||||
delay(alert_freq_step_time);
|
||||
}
|
||||
noTone(sound_pin);
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------
|
||||
// Measure relative humidity and return whether it is under/in/over range.
|
||||
|
||||
int check_rh()
|
||||
{
|
||||
float relative_humidity = sensor.readHumidity();
|
||||
if (relative_humidity < (target_humidity - 5)) {
|
||||
return -1;
|
||||
} else if (relative_humidity > (target_humidity + 5)) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------
|
||||
// Repeatedly check the humidity and light the neopixel and sound the buzzer as
|
||||
// appropriate, for as long as the reading is out of range.
|
||||
// Initial comparison result is passed in.
|
||||
|
||||
void warn_if_out_of_range(int comparison)
|
||||
{
|
||||
while (comparison != 0) {
|
||||
chirp(comparison > 0);
|
||||
delay(comparison_delay);
|
||||
comparison = check_rh();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void setup()
|
||||
{
|
||||
pinMode(sleep_pin, OUTPUT);
|
||||
digitalWrite(sleep_pin, LOW);
|
||||
// strip.setPixelColor(0, 0);
|
||||
// strip.show();
|
||||
|
||||
sensor.begin();
|
||||
warn_if_out_of_range(check_rh());
|
||||
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
digitalWrite(sleep_pin, HIGH);
|
||||
delay(50);
|
||||
digitalWrite(sleep_pin, LOW);
|
||||
delay(50);
|
||||
}
|
||||
20
Sensor_Plotting_With_Mu_CircuitPython/soil_moisture.py
Normal file
20
Sensor_Plotting_With_Mu_CircuitPython/soil_moisture.py
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
import time
|
||||
from adafruit_circuitplayground.express import cpx
|
||||
import touchio
|
||||
import simpleio
|
||||
import board
|
||||
|
||||
cpx.pixels.brightness = 0.2
|
||||
touch = touchio.TouchIn(board.A1)
|
||||
|
||||
DRY_VALUE = 1500 # calibrate this by hand!
|
||||
WET_VALUE = 2100 # calibrate this by hand!
|
||||
|
||||
while True:
|
||||
value_A1 = touch.raw_value
|
||||
print((value_A1,))
|
||||
|
||||
# fill the pixels from red to green based on soil moisture
|
||||
percent_wet = int(simpleio.map_range(value_A1, DRY_VALUE, WET_VALUE, 0, 100))
|
||||
cpx.pixels.fill((100-percent_wet, percent_wet, 0))
|
||||
time.sleep(0.5)
|
||||
28
Starry_Night/starry_night.py
Normal file
28
Starry_Night/starry_night.py
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
from busio import I2C
|
||||
from adafruit_seesaw.seesaw import Seesaw
|
||||
from adafruit_seesaw.pwmout import PWMOut
|
||||
from adafruit_motor import motor
|
||||
import board
|
||||
import time
|
||||
|
||||
# Create seesaw object
|
||||
i2c = I2C(board.SCL, board.SDA)
|
||||
seesaw = Seesaw(i2c)
|
||||
|
||||
# Create one motor on seesaw PWM pins 22 & 23
|
||||
motor_a = motor.DCMotor(PWMOut(seesaw, 22), PWMOut(seesaw, 23))
|
||||
motor_a.throttle = 0.5 # half speed forward
|
||||
|
||||
# Create drive (PWM) object
|
||||
my_drive = PWMOut(seesaw, 13) # Drive 1 is on s.s. pin 13
|
||||
my_drive.frequency = 1000 # Our default frequency is 1KHz
|
||||
|
||||
while True:
|
||||
|
||||
my_drive.duty_cycle = 32768 # half on
|
||||
time.sleep(0.8)
|
||||
|
||||
my_drive.duty_cycle = 16384 # dim
|
||||
time.sleep(0.1)
|
||||
|
||||
# and repeat!
|
||||
11
pylint_check
Executable file
11
pylint_check
Executable file
|
|
@ -0,0 +1,11 @@
|
|||
#!/bin/bash
|
||||
|
||||
function find_pyfiles() {
|
||||
for f in $(find . -type f -iname '*.py'); do
|
||||
if [ ! -e "$(dirname $f)/.circuitpython.skip" ]; then
|
||||
echo "$f"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
find_pyfiles | xargs pylint
|
||||
Loading…
Reference in a new issue