Devices & Components
Arduino Uno Rev3
Jumper wires (generic)
RGB Diffused Common Cathode
HC-05 Bluetooth Module
Breadboard (generic)
Software & Tools
MIT App Inventor 2
Arduino IDE
Project description
Code
Code
arduino
1/* 2 This program reads the the data received 3 by the HC-05 Bluetooth Module from the Android 4 app and writes the specific values to the RGB 5 LED. This creates different colors on the LED. 6 7 This program is made by Shreyas for 8 Electronics Champ YouTube Channel. 9 Please subscribe to this channel 10 Thank You 11*/ 12 13//Including the library 14#include <SoftwareSerial.h> 15 16//Creating a SoftwareSerial object 17SoftwareSerial HC05(3, 4); 18 19//Initialize the variables 20String data = ""; 21int red; 22int green; 23int blue; 24 25void setup() { 26 27 //Start Serial Communication 28 Serial.begin(9600); 29 HC05.begin(9600); 30 31 //Assign modes to the specific pins 32 pinMode(A0, OUTPUT); 33 pinMode(A1, OUTPUT); 34 pinMode(A2, OUTPUT); 35 36} 37 38void loop() { 39 40 //If HC-05 has received data... 41 if (HC05.available()){ 42 43 //Reads the data 44 data = HC05.readString(); 45 46 //Gets the value of each color 47 red = data.substring(0, 3).toInt(); 48 green = data.substring(3, 6).toInt(); 49 blue = data.substring(6, 9).toInt(); 50 51 //Writes the values to the specific pins 52 analogWrite(A0, red); 53 analogWrite(A1, green); 54 analogWrite(A2, blue); 55 56 } 57 58}
Downloadable files
Schematic
Schematic

Schematic
Schematic

Comments
Only logged in users can leave comments