Professional Documents
Culture Documents
You will learn how to program Arduino and blink a LED with it.
Components: Arduino UNO, Arduino Cable and a RGB LED and a Bluetooth Module (HC-05).
LEDs are small-sized and highly used components in electronics. You may find them in many
things from your TVs to cars. In this tutorial we are going to blink a LED using Arduino UNO.
What is schematic?
Here LEDs long leg goes to ground and other pins are connected as shown in Breadboard circuit
diagram above.
#include <SoftwareSerial.h>
char command;
String inputCommand;
// the setup function runs once when you press reset or power the board
void setup() {
bluetooth.begin(9600);
Serial.begin(9600);
pinMode(9, OUTPUT);
pinMode(10, OUTPUT);
pinMode(11, OUTPUT);
void loop() {
connectToBluetooth();
void connectToBluetooth(){
if (bluetooth.available() > 0)
{inputCommand = "";}
while(bluetooth.available() > 0)
command = ((byte)bluetooth.read());
inputCommand += command;
Serial.println(inputCommand);
if(inputCommand == "r")
ledTurnOn(11);
ledTurnOff(10);
ledTurnOff(9);
if(inputCommand =="g")
ledTurnOff(11);
ledTurnOn(10);
ledTurnOff(9);
if(inputCommand == "b"){
ledTurnOff(11);
ledTurnOff(10);
ledTurnOn(9);
}
if(inputCommand == "0")
ledTurnOff(11);
ledTurnOff(10);
ledTurnOff(9);
//analogWrite(pin, 255);
digitalWrite(pin,HIGH);
delay(100);
inputCommand = "";
//analogWrite(pin, 0);
digitalWrite(pin,LOW);
delay(100);
inputCommand = "";