So i'm still messing with the code and getting stuff figured out. What i am doing is making my arduino micro into a command interpreter, so that by using a serial monitor i can send a message and have the board do something in real time. like i could tell it to make a certain pin high or low or perhaps run short pieces of pre-made code. let's say i wanted to say hello to the arduino and have it say hello back on an lcd display.
// i send hello over serial
// arduino checks if my command equals hello
// arduino says "Hi, how are you?"
so how do i compare a serial input to an existing word like hello
i have this but it doesn't work
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
int prompt = 0;
void setup(){
lcd.begin(16, 2);
Serial.begin(9600);
}
void loop()
{
// when characters arrive over the serial port...
if (Serial.available()) {
// wait a bit for the entire message to arrive
delay(100);
// clear the screen
lcd.clear();
// read all the available characters
while (Serial.available() > 0) {
// ?? set the variable "prompt" to what is coming in over serial
prompt = (Serial.read());
// ?? does prompt equal hello
if (prompt == "hello") {
// since it does, print "hi how are you" to lcd
lcd.print("Hi, how are you?");
}
}
}
}
now i know there is a proper and/or shorter way of doing this, how would I?