Ramji Patel
Created October 21, 2020 © GPL3+

Arduino HC-05 BLUTOOTH RGB led

Control RGB led with your smart phone

AdvancedFull instructions provided83
Arduino HC-05 BLUTOOTH RGB led

Things used in this project

Hardware components

Arduino Pro Mini 328 - 5V/16MHz
SparkFun Arduino Pro Mini 328 - 5V/16MHz
×1
HC-05 Bluetooth Module
HC-05 Bluetooth Module
×1
Solderless Breadboard Full Size
Solderless Breadboard Full Size
×1
Jumper wires (generic)
Jumper wires (generic)
×1
RGB Diffused Common Cathode
RGB Diffused Common Cathode
×1
Resistor 1k ohm
Resistor 1k ohm
×8
SparkFun USB to Serial Breakout - FT232RL
SparkFun USB to Serial Breakout - FT232RL
×1

Software apps and online services

Arduino IDE
Arduino IDE
Arduino IDE 2.0 (beta)

Story

Read more

Schematics

Arduino HC-05 blutooth RGB led

pdf

Code

Arduino HC-05 blutooth code to control RGB led colors

C/C++
copy and paste on your editor
int ledred = 8;
int ledgreen =9;
int ledblue = 10;
char inSerial[15];
int tx = 1;
int rx = 0;


void setup() {
  // put your setup code here, to run once:
Serial.begin(9600);
pinMode(ledred, OUTPUT);
pinMode(ledgreen, OUTPUT);
pinMode(ledblue, OUTPUT);
pinMode(tx ,OUTPUT);
pinMode(rx, INPUT);
allpinslow();
}

void loop() {
  // put your main code here, to run repeatedly:
int i = 0;
int m = 0;
delay(500);
if(Serial.available() > 0){
  while(Serial.available() > 0){
    inSerial[i]=Serial.read();
    i++;
  }
  inSerial[i] = '\0';
  check_protocol(inSerial);
}}
void allpinslow()
{
  digitalWrite(ledred, LOW);
  digitalWrite(ledgreen, LOW);
  digitalWrite(ledblue, LOW);
}
void check_protocol(char instr[])
{
  int i = 0;
  int m = 0;
  Serial.println(instr);
if(!strcmp(instr,"red")){
  allpinslow();
  digitalWrite(ledred, HIGH);
  Serial.println("red on");
  for(m=0;m<11;m++){
    instr[m] = 0;
  }
  i = 0;
}
if(!strcmp(instr,"green")){
  allpinslow();
  digitalWrite(ledgreen, HIGH);
  Serial.println("green on");
  for(m=0;m<11;m++){
    instr[m] = 0;
  }
  i = 0;
}
if(!strcmp(instr,"blue")){
  allpinslow();
  digitalWrite(ledblue, HIGH);
  Serial.println("blue on");
  for(m=0;m<11;m++){
    instr[m] = 0;
  }
  i = 0;
}
else{
  for(m=0;m<11;m++){
    instr[m] = 0;
  }
i = 0;
}
}

Credits

Ramji Patel
26 projects • 18 followers
Myself Ramji Patel. I am an Engineering student and pursuing my B-Tech from Institute of engineering and rural Technology Prayagraj, India.

Comments