Go Down

Topic: Please help. any suggestion about message library (Read 526 times) previous topic - next topic

Stof

Hi, everyone. I'm a beginner

Pls help, can change massage all to lower string?

How can I do it?

Arduino recieve message from GSM Module. And i need to change its all to lower string. Now, I use message library.

#include <Messenger.h>
#include <String.h>
#include <stdio.h>

// Instantiate Messenger object with the message function and the default separator
// (the space character)
Messenger message = Messenger();


// Define messenger function
void messageCompleted() {
 Message = Message.ToLower();
 // This loop will echo each element of the message separately
 while ( message.available() ) {
   if ( message.checkString("on") ) {
     digitalWrite(13,HIGH);
   } else if ( message.checkString("of") ) {
     digitalWrite(52,HIGH);
   } else if ( message.checkString("off") ) {
     digitalWrite(13,LOW);
   } else if ( message.checkString("ooff") ) {
     digitalWrite(52,LOW);
   } else {
     break; }
 }
 
 
}

void setup() {
 // Initiate Serial Communication
 Serial.begin(115200);
 message.attach(messageCompleted);
 
 pinMode(13,OUTPUT);
 pinMode(52,OUTPUT);
}

void loop() {
 
 // The following line is the most effective way of
 // feeding the serial data to Messenger
 while ( Serial.available() ) message.process( Serial.read() );


}

Above codes won't work.

Thanks advance.

GrooveFlotilla

#1
Jan 11, 2010, 01:22 pm Last Edit: Jan 11, 2010, 01:22 pm by GrooveFlotilla Reason: 1
You could OR each character with 0x20, I think, as long as you know it is a letter A-Z.
A->a (0x41 -> 0x61)
Z->z (0x5A -> 0x7a)

Or use "tolower".
Some people are like Slinkies.

Not really good for anything, but they bring a smile to your face when pushed down the stairs.

Stof

Hi, Groove.
Thanks for your suggestion.
I will try.

Go Up