Tag Archives: led

Candlelight-Atmosphere with Arduino

7 Jan

Just a snipped of code that I have found for creating a candlelight-like light with a yellow LED attached to a PWM port of an Arduino (called here ledPin). You could probably add another red LED to optimize the effect, but for a first try it does not look too bad.

analogWrite(ledPin, random(120)+135);

Here is a small video of the setup in action:

Arduino-powered three-color lamp

31 Dec

This is a small example of interfacing Arduino with Android via bluetooth. I am using a very nice and convenient framework for this: Amarino, and basically followed one of the tutorials that are featured there to build a christmas decoration that I can control with my Android phone.

Arduino-powered three-color lamp

The setup consists of several components:

  • An Arduino Uno board with a bluetooth shield (I use the bluetooth shield from iteadstudio (v2.2))
  • A 3-color LED that is connected to the Arduino (via three PWM digital output pins)
  • An Android phone that is connected to the Arduino via bluetooth (using the Amarino framework). I used an HTC Legend running Froyo (2.2).
  • An Android App that uses the Amarino API to control the output value of the three PWM pins on the Arduino, thus enabling the user to set the color of the LED

Here is a picture of basically the same setup, but using three different LEDs instead of one 3-colored one. As you can see, the circuit is pretty simple: the LEDs are connected to three of the PWM digital output pins (9,10,11). Don’t forget to add capacitors, or you will probably burn your LEDs at some point.

Arduino-powered three-color lamp

The code that runs on the Arduino board depends on the Amarino library, that can be downloaded at http://www.amarino-toolkit.net/, and is pretty much the same that is documented in the abovementioned tutorial (with some slight changes to work with my setup). Basically, I just changed had to change the baud rate to 115200 as this is recommended for my bluetooth shield.

The App that is running on my Android phone is also the same like the one featured in the tutorial. In the current version it cannot be shared as an APK, but has to be compiled as the MAC Address of the Ardunio board that has to be controlled needs is hardcoded. So you will need the Android SDK in order to get the App installed, but then it works just fine. You also need the Amarino App to be installed on your phone, and connect it to your bluetooth shield in order to get the setup to work.