Hey I'm Bob and I like to make stuff, and today
I'm going to make some bike lights, that
are motion activated.
[INTRO]
This video is sponsored by Intel, and
they challenged me to come up with a
project, to take advantage of some of the
features of their brand-new arduino 101
board. This is an arduino compatible
board but it has a real-time operating
system and a 32-bit processor. The size
and shape is almost identical to the
Arduino Uno but it's got extra features
on it as well. On board, it's got
bluetooth low energy, which is really
awesome. And a six axis gyro and
accelerometer. You can get those features
in other modules, but it's really nice to
have it built on board for quick
prototyping. So, Intel asked me to come up
with a project using just the board and
the onboard sensors. And for a while I've
been considering making a lighting
system for a bike based on an arduino. So
in this case, I decided to use the
accelerometer on board to change the
brightness and color of the lights based
on motion. Right, let's check it out.
There wasn't really any circuitry to put
together, in fact i just had to solder a
few wires. In this case, I soldered on some
pins to the end of these wires and then
slid them into a connector. This
connector connects to the battery, just
so i can get power out and drive my
board and my lights.
Let me walk you through the electronics
for this project:
they're actually really simple, there's
not a whole lot together. Most of the
work on this project is actually in the
code, not in the circuit, so let's walk
through the electronics real quickly it
will look at the code. I've got the whole
thing prototyped here so let's walk
through it a little bit. I've got a LiPo
battery this is an 11.1 volt.
It's connected to the breadboard with a
switch so I can turn the whole thing on
and off. The breadboard is just handling
power. I've got power and ground coming
in here they split off into two
different places. The first one goes here
to this white box which is a voltage
converter this takes be essentially 12
volts down to 5 volts which is what the LEDs need.
So, the power for the LED is running through
here. The arduino 101 is powered through
here, with 11 volts now this board can
handle 7-12 volts as a voltage
input which is different than some of
the other boards a lot of them only take
5.
So this one is OK take 11 volts directly
from the battery. So, essentially we have
power, with a switch, going to the board,
which splits off into 5 volts or into 11
or 12 volts. The LEDs themselves are actually
controlled by this pin
they're just connected with one data
pin and a ground. So that's the
entire circuit, basically everything is
on this board it's just power. Before we
look at the code let me tell you what
this is actually supposed to do.
The idea is the bike would have two
lighting-states. One, when the bike is
stationary is going to have a parking
light on, which will be kind of an amber
color and once the bike starts moving
it'll turn into a white light and it
will be much brighter to make sure that
everybody around you on the road can see
you.
There's also going to be a small section
of lights behind the seat that will be
bright red and those will kind of act as a
taillight. There's not a whole lot of
code to make this happen but let's take
a look at it really quickly. The code I
started out with one of the example
programs that actually was installed
when i installed the libraries for this
board. I started with the example project
called "MotionDetect" essentially it does
exactly that, it just detects motion.
It has everything set up for the
threshold as to what it thinks is motion
and you can modify that just by changing
a couple of numbers. It does some basic
setup for the callbacks and then it just
prints out all this information into the
serial monitor. The loop here just
checks constantly to see if it's been
more than one second since the last
motion and then changes the LED on or
off based on that motion. Everytime
motion is detected it calls this event
callback and from that you can figure
out which axis the motion is happening
on in which direction it's going in
whether it's positive or negative on the
XY or Z axis. So I started with that code
and just added some LED code on top of
it. I brought in the Adafruit Neopixel
library i set up some basic information
about which pin it was connected to, how
many LEDs i had and how many lights I
wanted to be the brake light on the back.
I added a few variables but the biggest
one was to change the time out. Instead
of one second without motion I set it to
3 seconds. You can modify this line
right here to change it even further. At
the end of the set up, i just turned on
the leds and then ran my blank startup
function and that just runs the lights a
few times through sequence to let you
know that it started up and
ready to go. The loop is pretty much the same
except instead of turning on and off the
onboard led and just setting my strip to
white. Nothing really happens here in the
callback I just left it in so that you
could see it but essentially it just
happens all up here in the loop. If motion
is detected it sets them white, if
motion is not detected it sets them back
to the amber color. These functions set
white and set amber I just defined down
here at the bottom and all they do is
set the entire strip to a single color.
I'll have this code link down below it will
be on my github you can get it, modify it,
change it,  do whatever you want to
with it.
Let's test it out, all you have to do is flip
on, it does a little power-up sequence to
let me know that it's starting and then
it's ready. It's waiting for motion so as
soon as i move the bike in any way it
lights up it will stay on for about
three seconds and then power down until
there's motion again. As long as the
motion continues to stay lit up white. I
used a breadboard to prototype this
and that makes it really easy to plug
and unplug wires while you're testing. To
actually put it onto the bike and needed
it to be more permanent so it cut a
small piece of perfboard and then just
ran everything through the through holes
and soldered them in place. And in this case
really all I'm doing is putting all the
grounds into one place and all the power
wires into one place and soldering them
together.
The only other thing connected here is a
switch just so i can cut the power to
the board. I used some hot glue to hold the
pins in the arduino it'll keep them in
place but they'll come out very easily
when I'm ready. I measured the overall
size of these electronics and then made
a box using "Maker Case". It's a website that
lets you generate a template for making
a finger jointed box with a laser cutter.
I know not everybody has a laser cutter
and you don't need one at all you could
make a box in any way that you wanted to,
in fact you can put these electronics in
a plastic bag and it would work just
fine for prototyping. But in this case I
get to test out my new laser cutter and
make a finger joint box.
This only took about five minutes to cut
into pieces fit together perfectly.
This is a really quick and easy way to
make an enclosure for a prototype. If you
don't have a laser cutter and you're
curious about them
check your local makerspace because a
lot of them have them available. To
assemble this box i just used a little
bit of CA glue to hold it together.
I didn't use a ton of glue in case i
wanted to knock it apart and change
anything about it'll come apart pretty
easily. I set the battery in place and
glued-in a divider just to hold a
battery separate from the electronics
they did knock into each other too much.
I dropped everything in place and then
marked where I wanted the wires to pass
through and switch to be. I could have
added these two the laser cutter file
and actually had them cut, but i just used
that template right out of that website,
so it didn't have these things. I just
drilled some holes and popped these things
in place. I ran the wires through, plugged in
the two wires to the leds and then turned
on the power. And of course, I had to put my  sticker on it.
It works!
Since this is a prototype and I want to
be able to get back into this i just used
a zip tie to hold the top onto the box.
In fact i'm going to use zip ties to
attach this entire thing to the frame
because I can't use my own bike. The
frame on my bike is a little weird and
not really good for this application so
i borrowed a more typical bike from my
friend to test out with. So i'm also going
to use and zip ties just to attach the
lights to the frame to hold it in place
so i can test it out. Obviously how you
mount this and even the length of the
LED strip is going to be really
dependent on specific bike that you're
working with. Right let's put this thing
on and test it out. Zip ties work great
for testing but if you want a more
permanent solution you can get some
waterproof double-sided tape or some LED
strips even come with adhesive on the
back already.
That makes it quick and easy. And when I
was putting this on I realized that the
water bottle mount on the frame would be
a great way to mount the box next time.
After I got it fully mounted, I turned it
on to make sure everything still worked
and it did but it really shines at night.
It feels a little bit like Tron when
you're riding it.
It's cool because the lights mostly face
down so they're not shining up into your
eyes but it looks pretty awesome when
you're going down the street. It's
surprising how much they shine down onto
the street as well so it's almost like
having a headlight even though should
probably also have that too if you're
gonna be riding at night. It actually
worked out really well on the first try
and I think this is a really good first
step to a larger project. Having those
onboard sensors gives you a lot of
capability that you can add just the
code and since you can detect how far is
leaning in any direction imagine you put
LEDs on both sides of the bike and
change the brightness based on how the
bike is leaning you can get some like
auto turn signals. I'll have my code linked
down in the description, you can go get
it
add to it, change it, do whatever you want
to with it, I'll also have some information
about the arduino 101 on board if you're
interested in checking it out as well.
Thanks to Intel for sponsoring this
video it was really cool to work with
that board and I'm looking forward to
doing more of it in future. I hope you
liked this one I've got lots of other
electronics as well as a bunch of other
types of projects that you might be
interested in so be sure to check those
out and don't forget to subscribe.
That's it for this one thanks for
watching, I'll see you next time.
