Thursday, March 25, 2010

March Madness Challenge - Day 24

Yea, tonight some serial programming. With advice from Mark and John I got a nice Serial Echo program for the Arduino. I need to learn some basics about serial communication and have a tool to debug the communication from web page over Seriality to the Arduino.

/*
* Echo Serial on the Arduino
* with advice from Mark Sproul
*/
char str[10];


void setup() {
Serial.begin(9600);
Serial.println("Start");
}

void loop()
{
int ii = 0;
boolean keepgoing = true;
while (keepgoing)
{
while (Serial.available() )
{
{
str[ii] = Serial.read();
//Echo the character as you type
//Serial.write(str[ii]);
if (str[ii] == 0x0d )
{
keepgoing = false;
}
ii++;
}
}
}
str[ii] = 0;
Serial.println();
Serial.println(str);
delay(200);
}

No comments: