Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BLE on/off LED with red bear BLE Nano Kit #41

Open
nolispe280 opened this issue May 9, 2018 · 0 comments
Open

BLE on/off LED with red bear BLE Nano Kit #41

nolispe280 opened this issue May 9, 2018 · 0 comments

Comments

@nolispe280
Copy link

Hi,

I am trying to use the red bear BLE nano kit but am having difficulties with the Arduino program. Prior to the red bear I used a standard Arduino and BLE module to switch an LED on and off with my phone. Using the simple Blink_ble example it was pretty straightforward:

#include <SoftwareSerial.h>

char junk;
String inputString="";

void setup()                    // run once, when the sketch starts
{
 Serial.begin(9600);            // set the baud rate to 9600, same should be of your Serial Monitor
 pinMode(13, OUTPUT);
}

void loop()
{
  if(Serial.available()){
  while(Serial.available())
    {
      char inChar = (char)Serial.read(); //read the input
      inputString += inChar;        //make a string of the characters coming on serial
    }
    Serial.println(inputString);
    while (Serial.available() > 0)  
    { junk = Serial.read() ; }      // clear the serial buffer
    if(inputString == "a"){         //in case of 'a' turn the LED on
      digitalWrite(13, HIGH);  
    }else if(inputString == "b"){   //in case of 'b' turn the LED off
      digitalWrite(13, LOW);
    }
    inputString = "";
  }
}

Unfortunately doing the same with the redbear board seems much trickier! I have tried modifying the SimpleChat example but unfortunately using Serial.read() in the void loop function does not work (the variable is not recognised)

Anyone has had a similar issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant