You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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?
The text was updated successfully, but these errors were encountered:
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:
Unfortunately doing the same with the redbear board seems much trickier! I have tried modifying the SimpleChat example but unfortunately using
Serial.read()
in thevoid loop
function does not work (the variable is not recognised)Anyone has had a similar issue?
The text was updated successfully, but these errors were encountered: