0

UART triggert events
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

UART triggert events

by _Chris_M_ on Sun Nov 08, 2020 11:46 am

Hi everyone,
Im using the example sketch, bleuart, for the Adafruit Bluefruit nRF52 Libraries to communicate between my phone and the nRF52832 Bluefruit Feather. I want to send words/ numbers and have the nRF52832 Bluefruit Feather do different things. i.e. if i send the word hello it is supposed to send back via the Serial monitor "hi how are you doing". I thought i should just convert the uint_8 input to a string and then check via a switch case statement witch case I have and then process with the code in the statement. But I can't get the uint_8 to convert to something else.
Does someone have a good idea on how to convert the uint_8 input.
Chris

PS: i haven't changed anything in the code yet its just the basic example sketch.

_Chris_M_
 
Posts: 6
Joined: Wed Mar 04, 2020 9:18 am

Re: UART triggert events

by mikeysklar on Mon Nov 09, 2020 8:58 pm

Hi Chris,

Printing your unit_8 data as a char will give you readable text. There are many ways to do this, but you can cast to be explicit.

https://forum.arduino.cc/index.php?topic=297444.0

Code: Select all | TOGGLE FULL SIZE
void setup() {
  // put your setup code here, to run once:
  char myStr[20];
 
  myStr[0] = (char) 97;      // Use a cast
}

mikeysklar
 
Posts: 4634
Joined: Mon Aug 01, 2016 8:10 pm

Please be positive and constructive with your questions and comments.