Smart backpack with wireless charging pocket
FORGE
Finally, let’s set the upper limit to 255. If the
strength value is ever larger than 255, we’ll have it
reset to 250 and flip the direction value to start going
in the other direction:
elif strength >= (255):
strength = 250
direction = -direction
That’s it for the code! Save the file to your Trinket
M0, and watch your NeoPixel strip pulse. To change
the speed of the pulsing, adjust the time.sleep value,
or change the direction value. When you are happy
with your animation, move on to installing the Trinket.
For troubleshooting help and more tutorials about
programming the Trinket M0 with Circuit Python, check
out hsmag.cc/zucqvz. Here’s the full code listing:
import time
import board
import neopixel
numpix = 34 # Number of NeoPixels
pixpin = board.D0 # NeoPixels pin
strip = neopixel.NeoPixel(pixpin, numpix,
brightness=.5, auto_write=False)
strength = 0 # blue intensity
direction = 10 # direction of intensity
while True:
BLUE = (0, 0, strength)
strip.fill(BLUE)
strip.show()
time.sleep(0.03)
strength += direction
if strength <= 0:
strength = 10
direction = -direction
elif strength >= (255):
strength = 250
direction = -direction
INSTALL THE TRINKET
We’re almost done! All that is left is to securely
attach the Trinket near the charger. Sew the Trinket
in place through the four mounting holes located
in the corners of the board. Use a short mini USB
cable to connect the Trinket M0 to the charger, and
turn the charger on. If your NeoPixel strip lights up
and pulses in blue, you’re done! If not, check your
connections, and make sure your charger is charged.
Also, check that your phone charges when inserted
into its pocket.
WEAR IT!
You’re now ready to take your smart backpack out
for a spin! Turn the charger on for visibility while
out and about at night, and slip your phone into its
pocket whenever you need some juice. There are a
few more pins available on the Trinket M0, so you
can keep adding functionality to your backpack. An
accelerometer could help the lights pulse in time
with your steps, a GPS module could change the
colour based on your speed, or speakers could...
well, we will leave it up to you. However you
decide to use this project, be sure to let us know
at [email protected]!
Above
USB power banks
can power a wide
variety of things, and
don’t need soldering
Below
With everything in place, you’re good to go out and wear your
power-bank bag with pride