Tuesday, February 28, 2012

2nd project: Android controlled LED lighting

This project is about the use of an android phone to control LEDs via bluetooth. The system basically consist of an android phone, Arduino UNO, and bluetooth module. The android phone, through an application, sends data to Arduino via bluetooth. The Arduino UNO prototyping module then process the data from the android phone and control the brightness of each LED. The brightness control of each LED is implemented by using PWM pins of the Arduino UNO. The hardware can be powered by a 9V battery or a DC supply between 9 to 12V.

The Android Application
The application is made using sliders to vary the brightness of the LEDs. Each slider has a value of 0 to 255 from which  internet colors can be easily reproduced using the 3 sliders. Establishing the communication link is also done in the application. Basically, the app can search for other bluetooth devices, query for paired devices, establish RFCOMM channels/sockets, connect to a device, and send data over bluetooth.

Arduino UNO
Arduino UNO is an open-source electronics prototyping platform based on a flexible, easy-to-use hardware and software. It serves as the processor of the data from android phone. The value 0 to 255 from the android phone is translated to PWM wave with a frequency of approximately 490Hz to the pins 9, 10, and 11.

Bluetooth Module
The datasheet states that signal can reach up to 100m but actual distance may depend on the other communicating device. This module is using the UART interface in SPP configuration to connect to the Arduino UNO. In essence, the bluetooth module acts as a cable replacement between two devices.

Below is a demo video of the project.

Monday, February 13, 2012

Test and Debug

After writing your codes, it's time to test my application.

Using Android Virtual Emulator
One way to test your application is to run it on a virtual device.  The Android Virtual Device is included in the Android SDK tools.

1. Run the AVD manager.
On Eclipse, click Windows > Android SDK and AVD Manager.

2. Create a new virtual device.
- Name: virtual_galaxyS
- Target: Android 2.2
- SD card size: 512MiB
- Skin: Built-in: HVGA

* You can create several AVD with different screen sizes and Target versions.

3. Run your application.
On Eclipse, click Run > Run

* If you have multiple AVD, choose one that you want to use.

Now, have you made a good, working app already? Then good for you but most of the cases, it's not. So we need to debug.


In debugging, the DDMS and DEBUG perspective view in the Eclipse IDE are  helpful.

The Debug Perspective in