This is another illustration how to wire the Analog Led Strip using PWM on Microcontroller together with Bluetooth module and your Android smart phone. As your can see the diagram below we are using MOSFET to drive higher voltage pointed to RGB LED Strip. MOSFET metal–oxide–semiconductor field-effect transistor (MOSFET, MOS-FET, or MOS FET) is a type of field-effect transistor (FET). It has an insulated gate, whose voltage determines the conductivity of the device. This ability to change conductivity with the amount of applied voltage can be used for amplifying or switching electronic signals. For customizing the settings of your Bluetooth HC06 using AT Command please refer to this link.
Required Component
- Arduino Microcontroller, Teensy, ATMEGA328P on (USB to TTL), ATMEGA32U4
- Bluetooth HC06 Module
- MOSFET (N-Channel)
- 3014/3020/2835/5050/ Analog LED Strip
- 12v Power Adapter
- 5v Regulator(Optional)
- Jumper Wires / DuPont Wires
- Solder Less Bread Board
Wiring Guide
Android App.
https://play.google.com/store/apps/details?id=com.a14core.rgbselector
Source 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 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 |
#include <SoftwareSerial.h> /* 14CORE | Bluetooth RGB Led Strip Commander www.14core.com / Download the Android to google play | LED Commander | Wiring with Arduino UNO * UNO(PIN-10) - RED PIN * UNO(PIN-9) - GREEN PIN * UNO(PIN-11) - BLUE PIN * UNO SERIAL RX(PIN 2) - HC06 TX PIN * UNO SERIAL TX(PIN 3) - HC06 RX PIN * UNO 3.3v - HC06 VCC * UNO GND - HC06 GROUND * Wiring with MEGA * MEGA(PIN-10) - RED PIN * MEGA(PIN-9) - GREEN PIN * MEGA(PIN-11) - BLUE PIN * MEGASERIAL RX(PIN 2) - HC06 TX PIN * MEGASERIAL TX(PIN 3) - HC06 RX PIN * MEGA 3.3v - HC06 VCC * MEGA GND - HC06 GROUND * Wiring with Teensy (Refer to pin configuration) */ #define pRED 10 #define pGREEN 9 #define pBLUE 11 SoftwareSerial mySerial(2, 3); char state; int counter = 0; int pulse = 0; int timeRand (100); int speedPatroll(50); //SET SPEED FOR 2 state FLASHING int speedFading(10); //SET SPEED FOR FADING SEQUENCE int FRED, FGREEN, FBLUE; long RRAND, GRAND, BRAND, TRAND; void setup() { Serial.begin(9600); pinMode(pRED, OUTPUT); pinMode(pGREEN, OUTPUT); pinMode(pBLUE, OUTPUT); } void loop(){ if (Serial.available()>0){ state = Serial.read(); char start = char(state); if (start != 0){ } Serial.println(start); } if (state == 'o'){off();} if (state == 'n'){on();} if (state == 'w'){cwhite();} if (state == 'r'){cRed();} if (state == 'e'){cOrange();} if (state == 'y'){cYellow();} if (state == 'g'){cGreen();} if (state == 'l'){cLime();} if (state == 'b'){cBlue();} if (state == 's'){cSkyBlue();} if (state == 'p'){cPurple();} if (state == 'k'){cPink();} if (state == 'f'){strobeWhite();} if (state == 'q'){setPatroll();} if (state == 't'){fading();} if (state == 'i'){setRandom();} } /* 14CORE | FX */ // -------------------- void off(){ analogWrite(pRED, 0); analogWrite(pGREEN, 0); analogWrite(pBLUE, 0); } void on(){ analogWrite(pRED, 255); analogWrite(pGREEN, 255); analogWrite(pBLUE, 255); } void cwhite(){ analogWrite(pRED, 255); analogWrite(pGREEN, 255); analogWrite(pBLUE, 255); } void cRed(){ analogWrite(pRED, 255); analogWrite(pGREEN, 0); analogWrite(pBLUE, 0); } void cGreen(){ analogWrite(pRED, 0); analogWrite(pGREEN, 255); analogWrite(pBLUE, 0); } void cBlue(){ analogWrite(pRED, 0); analogWrite(pGREEN, 0); analogWrite(pBLUE, 255); } void cSkyBlue(){ analogWrite(pRED, 250); analogWrite(pGREEN, 200); analogWrite(pBLUE, 0); } void cOrange(){ analogWrite(pRED, 255); analogWrite(pGREEN, 153); analogWrite(pBLUE, 0); } void cYellow(){ analogWrite(pRED, 255); analogWrite(pGREEN, 255); analogWrite(pBLUE, 0); } void cLime(){ analogWrite(pRED, 100); analogWrite(pGREEN, 255); analogWrite(pBLUE, 100); } void cPurple(){ analogWrite(pRED, 102); analogWrite(pGREEN, 0); analogWrite(pBLUE, 153); } void cPink(){ analogWrite(pRED, 102); analogWrite(pGREEN, 100); analogWrite(pBLUE, 153); } void strobeWhite(){ if (counter < 3){ analogWrite(pRED,250); analogWrite(pGREEN,250); analogWrite(pBLUE,250); delay(200); analogWrite(pRED,250); analogWrite(pGREEN,250); analogWrite(pBLUE,250); delay(100); counter++; } } void fading(){ for (FRED = 0; FRED < 255; FRED++) { analogWrite(pRED, FRED); delay(speedFading); } for (FBLUE = 255; FBLUE > 0; FBLUE--){ analogWrite(pBLUE, FBLUE); delay(speedFading); } for (FGREEN = 0; FGREEN <255; FGREEN ++){ analogWrite(pGREEN, FGREEN); delay(speedFading); } for (FRED = 255; FRED > 0; FRED--) { analogWrite(pRED, FRED); delay(speedFading); } for (FBLUE = 0; FBLUE < 255; FBLUE++){ analogWrite(pBLUE, FBLUE); delay(speedFading); } for (FGREEN = 255; FGREEN > 0; FGREEN--){ analogWrite(pGREEN, FGREEN); delay(speedFading); } } void setRandom(){ RRAND = random(0, 255); //CHANGE VALUE FOR RANDOM RANGE NUMBERS GRAND = random(0, 255); //CHANGE VALUE FOR RANDOM RANGE NUMBERS BRAND = random(0, 255); //CHANGE VALUE FOR RANDOM RANGE NUMBERS TRAND = random(200, 800); //CHANGE VALUE FOR DELAY RANGE NUMBERS analogWrite(pRED, RRAND); analogWrite(pGREEN, GRAND); analogWrite(pBLUE, BRAND); delay(TRAND); analogWrite(pRED, 255); analogWrite(pGREEN, GRAND); analogWrite(pBLUE, BRAND); delay(TRAND); analogWrite(pRED, RRAND); analogWrite(pGREEN, 255); analogWrite(pBLUE, BRAND); delay(TRAND); analogWrite(pRED, RRAND); analogWrite(pGREEN, GRAND); analogWrite(pBLUE, 255); delay(TRAND); } void setPatroll(){ analogWrite(pRED, 255); analogWrite(pGREEN, 0); analogWrite(pBLUE, 0); delay(speedPatroll); analogWrite(pRED, 0); analogWrite(pGREEN, 0); analogWrite(pBLUE, 255); delay(speedPatroll); analogWrite(pRED, 0); analogWrite(pGREEN, 0); analogWrite(pBLUE, 0); delay(speedPatroll); analogWrite(pRED, 255); analogWrite(pGREEN, 0); analogWrite(pBLUE, 0); delay(speedPatroll); analogWrite(pRED, 0); analogWrite(pGREEN, 0); analogWrite(pBLUE, 255); } |