Clarification of my 2nd problem:
I wanted to make the local variable tweet from function printUserData to a global variable so this local variable can be accessed by the void loop() function. I learned that this is not a good practice, making local variables to global ones:
New programmers are often tempted to use lots of global variables, because they are easy to work with, especially when many functions are involved. However, use of non-const global variables should generally be avoided altogether!
source: http://www.learncpp.com/cpp-tutorial/42-global-variables/
Back to my 2nd and last problem here:
In order to make a variable from another function available inside the void loop() function you may do the following:
I am using the data type byte to make tweet as a byte variable. Inside the printUserData function tweet will return the value also to the void loop function(), since its stored inside byte tweet. This worked for me.
source: https://www.arduino.cc/en/Reference/Byte
byte printUserData(const struct UserData* userData) {
byte tweet = 0; // will return the value of this variable
Serial.print("data = ");
Serial.println(userData->pressure);
int intPressure = atoi(userData->pressure);
int print() {
if(intPressure != 0)
{
Serial.println("HIGH");
tweet = HIGH;
}
else
{
Serial.println("LOW");
tweet = LOW;
}
return tweet;
}
void loop() {
byte tweet=0;
val = digitalRead(LED_BUILTIN);
digitalWrite(LED_BUILTIN, tweet);
Serial.println("---");
Serial.println(val);
Serial.println("---");
...
}
Thank you for your help.