--> Project III - 15. Controlling LED Brightness with Android Device (Arduino Based) | basic arduino tutorial

Wednesday, August 9, 2017

Project III - 15. Controlling LED Brightness with Android Device (Arduino Based)

| Wednesday, August 9, 2017
Controlling LED Brightness with Android Device



Android application used is Bluetooth Electronics, the application can be downloaded via playstore, but admin also been provided on the Download Link at the bottom of this page. The LED control data is sent from Android using a bluetooth network serial to bluetooth module (HC-05).

Hardware Requirement
  • HC-05 Bluetooth Module
  • A Yellow LED
  • A Red LED
  • A Green LED
  • Arduino UNO
  • Power supply +5 Volt

Bluetooth HC-05 Module | Source


Block Diagram



Schematic


Arduino - LED Wiring


Arduino - HC-05 Module Wiring


Source Code/Sketch

#include <SoftwareSerial.h>
const int rxpin = 2;
const int txpin = 3;
SoftwareSerial hc05(rxpin, txpin);
int Red_Pin = 9; //Pin PWM untuk LED Merah
int Yellow_Pin = 10; //Pin PWM LED Kuning
int Green_Pin = 11; //Pin PWM LED Hijau
//variabel kecerahan LED, nilai dari 0 (off) s/d 255 (on maksimal)
int Red_value=0;
int Yellow_value=0;
int Green_value=0;
char BluetoothData;
void setup() {
pinMode(Red_Pin, OUTPUT);
pinMode(Yellow_Pin, OUTPUT);
pinMode(Green_Pin, OUTPUT);
hc05.begin(9600);
}
void loop() {
//jika ada data serial masuk seting nilai kecerahan masing2 LED
if (hc05.available()){
BluetoothData=hc05.read();
if(BluetoothData=='R') Red_value=hc05.parseInt(); //jika data merah
if(BluetoothData=='Y') Yellow_value=hc05.parseInt(); //jika data Kuning
if(BluetoothData=='G') Green_value=hc05.parseInt(); //jika data hijau
}
analogWrite(Red_Pin, Red_value);
analogWrite(Green_Pin, Green_value);
analogWrite(Yellow_Pin, Yellow_value);
delay(10);
}

How it Works

1. Connect the Arduino with Peripherals needed
2. Plug in the Power Source on the device
3. Compile and upload the script program above to your arduino

4. Customize your panel



5. Select text "A" and change name and color


6. Change Default Text to Yellow LED, and set Right Align and change the text color to yellow



7. Next Setting the output data that is sent when sliders are shifted




8. Setting the output data that is sent on the sliders shifted as shown below




9. If all has been adjusted then back to main menu, then connect bluetooth and select Connect Button



10. Select Discover> Pair> select HC-05> Connect> Done.


11. If the bluetooth module can not be read / installed, try to connect with ordinary bluetooth connection (manual connect in default setting menu, android device).


12. Select LED Brightness panel then select Run


13. You may sliding on the sliders on each LED, LEDs will brightly on when  the sliders Shifted to
       the right,  and turns dimmed as the sliders are shifted to the left




Video for Project III - 15. Controlling LED Brightness with Android Device (Arduino Based)







Required File 


Related Posts

No comments:

Post a Comment