Bluetooth Led
This Inscrutable shows you how to setup and connect an led light to an hm10 bluetooth module.
Materials
1: hm10 blue tooth module
2: led light
3: Arduino board
4: breadboard
5: male wires
6: a resister
Code
#include
#define LED_PIN 2
SoftwareSerial mySerial(7, 8); // RX, TX // Connect HM10 Arduino Uno // Pin 1/TXD Pin 7 // Pin 2/RXD Pin 8
void setup() { Serial.begin(9600); // If the baudrate of the HM-10 module has been updated, // you may need to change 9600 by another value // Once you have found the correct baudrate, // you can update it using AT+BAUDx command // e.g. AT+BAUD0 for 9600 bauds mySerial.begin(9600); }
void loop() { int c; if (mySerial.available()) { c = mySerial.read(); Serial.println(c); Serial.println("Got input:"); if (c == 110) { // Non-zero input means "turn on LED". Serial.println(" on"); digitalWrite(LED_PIN, HIGH); } if(c == 102) { // Input value zero means "turn off LED". Serial.println(" off"); digitalWrite(LED_PIN,LOW); } } }
Schematic
Steps of Setup
1.Connect 3.3V of Arduino to the VCC of HM-10
2. Connect GND of Arduino to the GND of HM-10
3.Connect D8 of Arduino to RX of HM-10
4.Connect D7 of Arduino to TX of HM-10
5. Connect D2 of Arduino to the long leg of LED along with a 220 ohm resistor
6.Connect the short leg of LED with the GND of Arduino
7. Download bluetooth app to connect to hm10
8. Connect to the hm10
9. Send command on to turn on light
10.Send off to turn light off