Controlling a led strip Arduino Project with ArduinoBt

As promised on The last article (HERE), now we can have a simple app on Arduino. It will allow the android app, (ArduinoBT) control a led strip. In this project I used an Arduino Nano. For the bluetooth, I used pins 5 and 6 (rx=5 and tx=6), and for the led strip I used pins 10,11 and 13 ( R=10 G=11 B=13). I used 10,11 and 13, because they allow pwm, so if I want to improve my project later, I can use this feature.

If you wan’t to buy an arduino nano click HERE
to buy an jymcu-bluetooth module CLICK HERE

I didn’t want to risk my little arduino nano, so i used some tip120 ‘s, and an external source to drive the led strip, the diagram for each connection is showed below.

Th led strip has 4 pins, Vcc R,G and b. R,G and B will be connected on the tip120 collector. Vcc Will go directly to Vcc12 external power. The base will be connected to the arduino’s pins, and the emiter at ground. NEVER ATTACH BOTH VCC ( arduino and 12. Vcc ) TOGETHER! The ground pin must be connected both at Arduino and the 12 vcc external power source.

The complete connection diagram is showed here.

BtLedStrip

This one shows the right position of TIP pins ( disregard the Control pins on Arduino, since this project is a little different. I Used pins 10, 11 and 13 )

Led Strip Connection

On my program I will use buttons 1, 2 and 3 of ArduinoBt to control the led. The will toggle each led on and off. 1 will toggle red, 2 for green and 3 for blue.

Now alll you have to do is to compile, upload to arduino, and connect to ArduinoBt, now just press 1, 2 and 3 and control your led strip!

The real circuit is showed bellow, it is a little messy, but it does work!

Arduino Bluetooth LedStrip

Arduino Bluetooth LedStrip

Enjoy!

I also made a small VIDEO

The source code for Arduino is listed below:

#include
SoftwareSerial mySerial(5,6); // RX, TX
const int ledRed = 10; // the number of the LED pin
const int ledGreen = 11; // the number of the LED pin
const int ledBlue = 13; // the number of the LED pin

void setup()
{
// Open serial communications and wait for port to open:
Serial.begin(9600);
// set the data rate for the SoftwareSerial port
mySerial.begin(9600); // Or 9600, depending on your firmware version
pinMode(ledRed, OUTPUT);
pinMode(ledGreen, OUTPUT);
pinMode(ledBlue, OUTPUT);

//while (!Serial) {
//; // wait for serial port to connect. Needed for Leonardo only
//}

Serial.println(“Ready to forward AT commands to JY-MCU: “);

}

int comando,red=0,green=0,blue=0;

void loop() // run over and over
{

if (mySerial.available()) {
comando=mySerial.read();
switch (comando)
{
case ‘1’:
if ( red )
red=0;
else
red=1;
digitalWrite(ledRed, red);
break;
case ‘2’:
if ( green )
green=0;
else
green=1;
digitalWrite(ledGreen, green);
break;
case ‘3’:
if ( blue )
blue=0;
else
blue=1;
digitalWrite(ledBlue, blue);
break;
}
Serial.write(comando);
}
if (Serial.available())
mySerial.write(Serial.read());

//Serial.println(“alo”);
}

One thought on “Controlling a led strip Arduino Project with ArduinoBt

  1. Pingback: Arduino and Ethernet Module enc28j60 - EletroFun