construction
2. The trigger values
are defined by A_max
and A_min in the final
code (tiltdetection.ino).
3. Download the fi-
nal code and open it in
Arduino IDE.
4. Put the values for
Fig. 4: Actual-size, single-side PCB for the
A_max and A_min in
Arduino-based tilt detector the final code as shown
in Fig. 7.
5. Program Arduino
again with this new
code and the system is
Fig. 6: Screenshot of values of X, Y and Z axes ready to work.
6. If the angular tilt
is within the thresh-
old, red LED will glow.
Otherwise LEDs corre-
sponding to each direc-
Fig. 5: Component layout for the PCB tion will glow.
7. You can see the
Parts List same on serial port also.
Semiconductors:
Connect the USB and
ACC1 - Accelerometer module open the serial port in
LED1-LED5 - 5mm LED
Arduino environment.
Resistor (1/4-watt, 5% carbon):
R1 - 220-ohm You will see on the seri-
Miscellaneous: al port forward if tilted
CON1 - 6-pin connector forward, and similarly
CON2 - 7-pin connector
Board1 - Arduino Uno board for the other directions.
Fig. 7: Screenshot of Arduino Uno programming
Software
efy Note we need to trigger values for LEDs, The software is written in Arduino
The source code of this project is and for that: programming language and the
included in this months EFY DVD (i) Connect the Arduino board to board is programmed using Arduino
and is also available for free down- your computer with USB cable. IDE software. ATmega328 on Ar-
load on www.efymag.com website. (ii) Download the source code (test. duino Uno comes pre-burnt with a
ino) and burn it on the Arduino board. bootloader that allows you to upload
the central LED (red) will glow. Pins 8 (iii) Open the serial port from Ar- new code without the use of external
through 12 of Board1 are connected to duino environment and press reset hardware programmer. It commu-
LEDs as shown in Fig. 3. button. nicates using the original STK500
(iv) You will see the screen shown protocol. You can also bypass the
Construction and testing in Fig. 6 on which the values of x, y, bootloader and program the micro-
Actual-size, single-side PCB for the and z axes will vary corresponding to controller through ICSP (in-circuit
Arduino-based tilt detector is shown the position of your accelerometer. serial programming) header, but us-
in Fig. 4 and corresponding compo- (v) Tilt it to the left and note the ing bootloader is quicker and easier.
nent side layout is shown in Fig. 5. value for A_max after which you Select Arduino Uno from the Tools
Suitable connectors are provided on want the corresponding LED to glow. > Board menu (according to the mi-
the PCB to interface accelerometer The same trigger will be applied for crocontroller on your board) in the
and Arduino Uno board. To test the backward tilt too. Arduino IDE and burn the program
circuit, check the correct voltage levels (vi) Tilt it to the right and note the through standard USB port in the
as shown in the test points table. value for A_min after which you computer.
For functional testing follow want the corresponding LED to glow.
below-mentioned steps: The same trigger will be applied for The author is a B.Tech in electronics and com-
1. After assembling the circuit, first forward tilt too. munication from Lovely Professional University
102 September 2013 | Electronics For You www.efymag.com