Another guide how to wire the HCo6 and 4 Channel Relay for switching, The HC06 modules uses BlueCore is a single chip radio and baseband IC for Bluetooth 2.4GHz system including enhance data rates (EDR) to 3Mbps. for more details please refer the the CSRBC417 Datasheet.
The BC417143B interfaces to 8Mbit of external flash memory. When used with the CSR Bluetooth software stack, it provides a fully compliant Bluetooth system to version 2.0 of the specification for data and voice communication.
The chip BlueCore has been designed to reduce the number of external components required. The device incorporates auto-calibration and built in self-test BIST routine to simplify the development. All hardware and device firmware is fully complaints with the Bluetooth version 2.0 plus EDR specification.
Configuration and customization settings using AT Command please refer to this link.
Required Components
- Arduino Nano, UNO, MEGA, DUE, LEO
- HC06 Bluetooth Module
- 4 Channel Relay Module
- Solder Less Breadboard
- Jumper Wires / DuPont Wire
Android App.
https://play.google.com/store/apps/details?id=com.a14core.relay
Wiring Diagram
Sketch Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
/* ********************************************************************************************** 14CORE | Test Code for Android /HC06/ Arduino Relay Commander V1.1 # .:+osysso++:` # `+yhs/-` `-+s+` `:/+++++++++` .:/++ooo++/-` .ooooooooooo+: :///////////- # `odh/` `:y+` /ddhsooooooo+ /hddhsooooydddh sdddoooooosdddy` `////////////` # -hds` `sy. +ddy` .ddd: sddy.dddo +ddd- .-----------` # `hds :sssss/ -ossssso-yy` `hdd: oddy `ddd/oddd:......+dddo .++++++++++++ # +dd` :sdddh` :ydddddddo +y/ .ddd+........ `hddy:.....:yddy.hdddddddddddy+. ```````````` # ydy .hddd/+hdddhydddh/.+yo /hdddddddddd. :shddddddddhs/`+ddd:````-yddy- :ooooooooooo+ # odh` sdddooyyyyyhddddyy.sy+ ` `......... ``.... ....` ```...` ` `` `` ` # -dd+`::::` .:::- /yy. -oos+:-oos+--oos+: /o `+y o/: o:+/ h:`yos /+-`/+/+ s:y/y. # /dd/ `+yy: +//+ +/:+ +/:+ -. `/ -:o.:/:`//+- + +:- :`-+:`://: +`o`+. # -yds. `/yys- .`-.. .``` ```` .`` ` ` ``` ``-..` ` # :ydy/.`````.-/oyhs: `+++oo+oo+:.+-++/-/ooo+o +:o/oo///:+/ # .:oyhhhhhhhso:` `. ``` * **********************************************************************************************/ int R1 = 9; int R2 = 10; int R3 = 11; int R4 = 12; char data = 0; void setup() { Serial.begin(9600); pinMode(R1, OUTPUT); pinMode(R2, OUTPUT); pinMode(R3, OUTPUT); pinMode(R4, OUTPUT); } void loop() { if (Serial.available()) { data = Serial.read(); Serial.print(data); } if(data == '0'){ digitalWrite(R1, 0); } if(data == '1'){ digitalWrite(R1, 1); } if(data == '2'){ digitalWrite(R2, 0); } if(data == '3'){ digitalWrite(R2, 1); } if(data == '4'){ digitalWrite(R3, 0); } if(data == '5'){ digitalWrite(R3, 1); } if(data == '6'){ digitalWrite(R4, 0); } if(data == '7'){ digitalWrite(R4, 1); } } |
Downloads
Download CSRBC417 Datasheet | PDF
Download AT-Command Reference | PDF
there is an error on the code.
Missing If Statement and void loop()
fix.
I’m upload your program but nothing happend. Relay stays on, when I’m connect my phone and using your app but doesn’t off the relay.
Please give me soluition. I’m waiting for your reply.
1. if your using MCU without serial communication it will not work.
2. if your wiring to a different Digital Pins will not also work.
try to change the char data start from 1 to 8
if (data == ‘1’){digitalWrite(R1, HIGH)}
if (data == ‘2’){digitalWrite(R2, HIGH)}
and so on…..
I’m following your steps one by one. I’m using my smart phone for programming arduino nano. But i mistakenly press reset button.
Is this code case sensitive??
Can i reprogramme my mcu?
Is this code and MCU case sensitive??
I’m using HC06 bluetooth module for serial communication.
Can i reset my MCU and reprogram again?
Pressing the reset button is not related to the code. reset button is just to reset the micro-controller return the setup & loop state, the same like your going 2 remove the power and put-it back. yes you can reprogram your MCU using bootloader see this link. > https://www.arduino.cc/en/Hacking/Bootloader
Thank you .
It is working very nice. Thank you so much.