CC2541+Arduino+12v LED strip

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. :confused:

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).

From an Arduino point of view there's no difference between the Android and the iPhone. Getting an app for the iPhone that supports the BTLE GATT is a problem you should ask on an iPhone forum (or write one yourself).

pylon:
From an Arduino point of view there's no difference between the Android and the iPhone. Getting an app for the iPhone that supports the BTLE GATT is a problem you should ask on an iPhone forum (or write one yourself).

Why is my phone not recognising the arduino or working to change the light then? I have follow the tutorials to the letter

Any advice???

Why is my phone not recognising the arduino or working to change the light then?

Maybe your phone is not supporting the BTLE GATT?

I have follow the tutorials to the letter

But you forgot to post the links to the tutorials you followed. We have no clue about what you've done or not done.

I have actually tried few.

Started with Beginner's Guide to Using LED Strips with Arduino - YouTube which is the auto run.
But I want the light to be iPhone controlled so I tried Bluetooth LED strip arduino control Android App - YouTube but it obviously uses a HC-05/06 instead of the HM-10 and they are using an android instead of an iPhone.

Hence my original request for help on this post and someone who can help me use my iPhone to control the LED strip similarly.

Will this work? And what would the code be for an Arduino Uno+HM-10+12v LED strip controlled by an iPhone.

But I want the light to be iPhone controlled so I tried https://www.youtube.com/watch?v=JScZd7AAJwI but it obviously uses a HC-05/06 instead of the HM-10 and they are using an android instead of an iPhone.

The HC-05/06 is a Bluetooth device but the HM-10 is a Bluetooth Low Energy device. Despite the name these are completely different standards. About the only thing they have in common is the frequency band they use but WiFi is using the same.

What App are you trying to use on the iPhone? Do you write your own?

Wouldn’t know how to write my own app. As I said before, I’m quite new in all this.
I have tried with all imaginable apps. Magic home, Smart light, Magic blue, LED control, LED BLE, Magic light, BT light, 4remote BT, Handy BLE, BLE scanner and LightBlue (The last one works to find the CC2541 and connect but when going to the other apps the CC2541 does not show).

Are there any specific coding for these apps?

pylon:
The HC-05/06 is a Bluetooth device but the HM-10 is a Bluetooth Low Energy device. Despite the name these are completely different standards. About the only thing they have in common is the frequency band they use but WiFi is using the same.

What App are you trying to use on the iPhone? Do you write your own?

Would you recommend to use a different component? Or can I use what I have and have a different code I am not really aware of?

Would it be better for me to buy a different component to connect my iPhone to the arduino to control the 12v LEDs? And what component and code would that be?
Thanks

Hi I have been looking around and have been able to find the instruct-able "Arduino - Control WS2812b LED strip via Bluetooth with iPhone or Android - YouTube" but as I am so new at all this and frankly not very good at understanding all the code I have been unable to adjust the code to suit my 12v LED connecting to the CC2541.

Is there anyone that can give me an insight on what part of the code to change so I can use the tutorial for the LED strip I already have and the CC2541?

All the help is very much appreciated.

Thank you in advance

Maybe you should use an HC06 and something like teraterm for iphones

I have done some research and have seen that the HC-06 cannot be paired with an iPhone. And to be completely honest I want to use the components I already have as I am kinda out of funds :sweat_smile:

So I have kept on checking and I have found a web site called circuito (https://www.circuito.io/app?components=9442,11022,12021,395589) that helps you out with the code just by placing the components you have. However, when using the code it says

"/tmp/634353255/Circuito_12vRGBNanoHM10/Circuito_12vRGBNanoHM10.ino:77:17: error: 'class RGBLed' has no member named 'turnOff'

LedStripRGB.turnOff(); // 3. turns LED Strip RGB off (showing no color). Change the values in the brackets to alter the color."

// Include Libraries
#include "Arduino.h"
#include "BLEHM10.h"
#include "RGBLed.h"


// Pin Definitions
#define BLEHM10_PIN_RXD	10
#define BLEHM10_PIN_TXD	11
#define LEDSTRIPRGB_PIN_SIGR	6
#define LEDSTRIPRGB_PIN_SIGG	5
#define LEDSTRIPRGB_PIN_SIGB	3



// Global variables and defines
String blehm10Str = "";
#define LedStripRGB_TYPE COMMON_CATHODE
// object initialization
RGBLed LedStripRGB(LEDSTRIPRGB_PIN_SIGR,LEDSTRIPRGB_PIN_SIGG,LEDSTRIPRGB_PIN_SIGB,LedStripRGB_TYPE);
BLEHM10 blehm10(BLEHM10_PIN_RXD,BLEHM10_PIN_TXD);



// define vars for testing menu
const int timeout = 10000;       //define timeout of 10 sec
char menuOption = 0;
long time0;

// Setup the essentials for your circuit to work. It runs first every time your circuit is powered with electricity.
void setup() 
{
    // Setup Serial which is useful for debugging
    // Use the Serial Monitor to view printed messages
    Serial.begin(9600);
    while (!Serial) ; // wait for serial port to connect. Needed for native USB
    Serial.println("start");
    
    blehm10.begin(9600);
    //This example uses HM-10 BLE to communicate with an Android or iOS device.
    //For Android download Hm BLE Terminal from google play store, or any other BLE app.
    //For iOS download LightBlue from App Store, or any other BLE app.
    //On both apps, pair and connect to your HM-10
    //You should see this message your Smartphone 
    blehm10.println("BLE On....");
    LedStripRGB.turnOff();              // Start with  LED Strip RGB turned off
    menuOption = menu();
    
}

// Main logic of your circuit. It defines the interaction between the components you selected. After setup, it runs over and over again, in an eternal loop.
void loop() 
{
    
    
    if(menuOption == '1') {
    // HM-10 BLE Bluetooth 4.0 - Test Code
    //Receive String from bluetooth device
    if (blehm10.available())
    {
        //Read a complete line from bluetooth terminal
        blehm10Str = blehm10.readStringUntil('\n');
        // Print raw data to serial monitor
        Serial.print("BT Raw Data: ");
        Serial.println(blehm10Str);
    }
    //Send sensor data to Bluetooth device  
    blehm10.println("PUT YOUR SENSOR DATA HERE");

    }
    else if(menuOption == '2') {
    // LED RGB Strip - Bare (1m) - Test Code
    // The LED Strip RGB will turn PURPLE for 500ms(half a second) and turn off
    LedStripRGB.setRGB(160, 3, 255);    // 1. sets LED Strip RGB color to purple. Change the values in the brackets to (255,0,0) for pure RED, (0,255,0) for pure GREEN and (0,0,255) for pure BLUE.
    delay(500);                         // 2. change the value in the brackets (500) for a longer or shorter delay in milliseconds.
    LedStripRGB.turnOff();        // 3. turns LED Strip RGB off (showing no color). Change the values in the brackets to alter the color.
    delay(500);                         // 4. change the value in the brackets (500) for a longer or shorter delay in milliseconds.  
    }
    
    
    
    if (millis() - time0 > timeout)
    {
        menuOption = menu();
    }
    
}



// Menu function for selecting the components to be tested
// Follow serial monitor for instrcutions
char menu()
{

    Serial.println(F("\nWhich component would you like to test?"));
    Serial.println(F("(1) HM-10 BLE Bluetooth 4.0"));
    Serial.println(F("(2) LED RGB Strip - Bare (1m)"));
    Serial.println(F("(menu) send anything else or press on board reset button\n"));
    while (!Serial.available());

    // Read data from serial monitor if received
    while (Serial.available()) 
    {
        char c = Serial.read();
        if (isAlphaNumeric(c)) 
        {
            if(c == '1') 
    			Serial.println(F("Now Testing HM-10 BLE Bluetooth 4.0"));
    		else if(c == '2') 
    			Serial.println(F("Now Testing LED RGB Strip - Bare (1m)"));
            else
            {
                Serial.println(F("illegal input!"));
                return 0;
            }
            time0 = millis();
            return c;
        }
    }
}

/*******************************************************

*    Circuito.io is an automatic generator of schematics and code for off
*    the shelf hardware combinations.

*    Copyright (C) 2016 Roboplan Technologies Ltd.

*    This program is free software: you can redistribute it and/or modify
*    it under the terms of the GNU General Public License as published by
*    the Free Software Foundation, either version 3 of the License, or
*    (at your option) any later version.

*    This program is distributed in the hope that it will be useful,
*    but WITHOUT ANY WARRANTY; without even the implied warranty of
*    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
*    GNU General Public License for more details.

*    You should have received a copy of the GNU General Public License
*    along with this program.  If not, see <http://www.gnu.org/licenses/>.

*    In addition, and without limitation, to the disclaimers of warranties 
*    stated above and in the GNU General Public License version 3 (or any 
*    later version), Roboplan Technologies Ltd. ("Roboplan") offers this 
*    program subject to the following warranty disclaimers and by using 
*    this program you acknowledge and agree to the following:
*    THIS PROGRAM IS PROVIDED ON AN "AS IS" AND "AS AVAILABLE" BASIS, AND 
*    WITHOUT WARRANTIES OF ANY KIND EITHER EXPRESS OR IMPLIED.  ROBOPLAN 
*    HEREBY DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT 
*    NOT LIMITED TO IMPLIED WARRANTIES OF MERCHANTABILITY, TITLE, FITNESS 
*    FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND THOSE ARISING BY 
*    STATUTE OR FROM A COURSE OF DEALING OR USAGE OF TRADE. 
*    YOUR RELIANCE ON, OR USE OF THIS PROGRAM IS AT YOUR SOLE RISK.
*    ROBOPLAN DOES NOT GUARANTEE THAT THE PROGRAM WILL BE FREE OF, OR NOT 
*    SUSCEPTIBLE TO, BUGS, SECURITY BREACHES, OR VIRUSES. ROBOPLAN DOES 
*    NOT WARRANT THAT YOUR USE OF THE PROGRAM, INCLUDING PURSUANT TO 
*    SCHEMATICS, INSTRUCTIONS OR RECOMMENDATIONS OF ROBOPLAN, WILL BE SAFE 
*    FOR PERSONAL USE OR FOR PRODUCTION OR COMMERCIAL USE, WILL NOT 
*    VIOLATE ANY THIRD PARTY RIGHTS, WILL PROVIDE THE INTENDED OR DESIRED
*    RESULTS, OR OPERATE AS YOU INTENDED OR AS MAY BE INDICATED BY ROBOPLAN. 
*    YOU HEREBY WAIVE, AGREE NOT TO ASSERT AGAINST, AND RELEASE ROBOPLAN, 
*    ITS LICENSORS AND AFFILIATES FROM, ANY CLAIMS IN CONNECTION WITH ANY OF 
*    THE ABOVE. 
********************************************************/

Where would the variable 'turn off' have to be?

Thanks for the help

Have anyone encounter the same issues as me?