Hi I have been trying to set up an iPhone controlled LED strip. I have managed to set a loop as I am totally new to these kind of projects.
So all in all the arduino I have programmed is working in a constant fading loop as per many tutorials on the web with the code below. However, none of these tutorials mention the addition of a HM-10 controlling the LED via BLE with an iPhone (all of them show them controlled by android).
Can someone help me out with the coding for the CC2541 for the controls of the LED?
int ledPinR = 9;
int ledPinG = 5;
int ledPinB = 6;
void setup() {
}
/* Note:
When driving LED's using common anode LED AMP's you have to inverse the duty cycle,
i. e. 255 is off and 0 is full power.
*/
void loop() {
// Red
for(int fadeValue = 255 ; fadeValue >= 0; fadeValue -=5) {
analogWrite(ledPinR, fadeValue);
delay(30);
}
for(int fadeValue = 0 ; fadeValue <= 255; fadeValue +=5) {
analogWrite(ledPinR, fadeValue);
delay(30);
}
// Green
for(int fadeValue = 255 ; fadeValue >= 0; fadeValue -=5) {
analogWrite(ledPinG, fadeValue);
delay(30);
}
for(int fadeValue = 0 ; fadeValue <= 255; fadeValue +=5) {
analogWrite(ledPinG, fadeValue);
delay(30);
}
// Blue
for(int fadeValue = 255 ; fadeValue >= 0; fadeValue -=5) {
analogWrite(ledPinB, fadeValue);
delay(30);
}
for(int fadeValue = 0 ; fadeValue <= 255; fadeValue +=5) {
analogWrite(ledPinB, fadeValue);
delay(30);
}
// White
for(int fadeValue = 255 ; fadeValue >= 0; fadeValue -=5) {
analogWrite(ledPinR, fadeValue);
analogWrite(ledPinG, fadeValue);
analogWrite(ledPinB, fadeValue);
delay(30);
}
for(int fadeValue = 0 ; fadeValue <= 255; fadeValue +=5) {
analogWrite(ledPinR, fadeValue);
analogWrite(ledPinG, fadeValue);
analogWrite(ledPinB, fadeValue);
delay(30);
}
}
I have found some setup for the BLE board "{
Serial.begin(9600); //Begin the serial communication
pinMode(RGB_red, OUTPUT); //Initialize RGB_red pin as output
pinMode(RGB_green, OUTPUT); //Initialize RGB_green pin as output
pinMode(RGB_blue, OUTPUT); //Initialize RGB_blue pin as output
// Open serial communications and wait for port to open:
Serial.begin(9600);
Serial.println("Serial began");
blueToothSerial.begin(9600);
}"
But all the app I can find on for iPhone do not recognise the board even after connecting to it with Lightblue scanner.
I would really really really really appreciate any help.