Hey guys,I have problem about how to input string ex:"0,0,0" for system action,thanks
serial_s.ino (487 Bytes)
Hey guys,I have problem about how to input string ex:"0,0,0" for system action,thanks
serial_s.ino (487 Bytes)
word chss=Serial.read();
Don't use non-standard types unless you have a compelling reason. Being a Microsoft-butt-kisser is NOT a compelling reason.
The Serial.read() method does NOT return a word.
if(chss == "hallo"){
The byte that you got can NOT possibly equal a string.
There was no reason to attach your code when it is well within the posting limits.
void setup() {
Serial.begin(9600);
pinMode(7,OUTPUT);
pinMode(8,OUTPUT);
digitalWrite(8,HIGH);
}
void loop() {
if(Serial.available()){
char ch=Serial.read();
word chss=Serial.read();
String chs=Serial.readString();
String g="300,300,300";
Serial.print("lalalala~~");
if(chss == "hallo"){
digitalWrite(7,HIGH);
Serial.println("chss.");
}
else if(ch == 'G'){
digitalWrite(7,LOW);
Serial.println("cobi.");
}
else{
Serial.println("不要");
}
}
}
What IS your problem? Apparently, you have not read this:
http://forum.arduino.cc/index.php?topic=396450.0
Have a look at the parse example in Serial Input Basics - simple reliable ways to receive data.
...R