Blinky Ball Project
Blinky Ball Project
Blinky Ball Project
Components
1. Printed Circuit Board(Cut in semicircular shape with cutout in center)
2. Shift Register 74HC595
3. LEDs and Resistors
4. Dual Axis Accelerometer
5. Battery
Main IC used
1. Shift register - Sometimes we run out of pins in Arduino board. So Shift
registers helps in extending number of output pins (just like multiplug). Shift
register mainly used here is 74HC595. This is an "8-bit serial-in, serial or
parallel-out shift register with output latches; 3-state". 3 states are LOW, HIGH
and HIGH IMPEDANCE. We can use it to control 8 outputs at a time while
taking only a few pins on microcontroller (Arduino). We can link multiple
registers together to extend output even more. There are 2 types of pins
Clock pin and Latch Pin. When Clock pin goes from Low to High, Shift
Register reads data from data pin and stores it in some internal memory.
When latch pin goes from LOW to HIGH the stored data gets shifted from shift
registers to output pins, thus lighting the LEDs.
Algorithm
Initialize clockpin, datapin, latchpin of shift register IC and declare them as OUTPUT
in setup () method; Set X & Y pins of accelerometer as Analog INPUTS in setup ()
method. Declare an accelerometer function to change the raw inputs X & Y from
accelerometer to actual acceleration in X & Y direction. Now in the loop () method
check the acceleration in X & Y direction using the accelerometer function created
before. First of all we have to orient the accelerometer in the ball so that in the idle
position when leds are not glowing or only glowing at poles (depends on us) its Yaxis is in upward direction and X-axis is any direction. Now in the loop() method we
have to check the accelerations in X & Y direction using accelerometer function and
if magnitude of acceleration in y direction decreases led starts glowing and stays on
one by one in upward direction gradually, and when the acceleration becomes 0 turn
on all the LEDs. Check when acceleration starts increasing in y direction start turning
off the LEDs from initial bottom position gradually such that when the acceleration in
Y direction is equal to g(acc. due to gravity) only the bottom most LED is glowing.
Here we will use the byte datatype to send the output signals to the shift register so
as to control the LEDs connected to it.