I am building a web controlled tank that utilizes the Arduino Ethernet Controller. Prior to using the Ethernet controller, I would drive my netbook around on the tank. (Original Code posted below). Is there a way to easily implement this code to make it work on a web server? The original code uses incomingByte to listen for data sent over serial. Can the ethernet shield just send serial data to the arduino?
Original Code:
/*
*/
int ledPin13 = 13; //
int ledPin12 = 12; //
int ledPin11 = 11; //
int ledPin10 = 10; //
int ledPin9 = 9; //
int ledPin8 = 8; //
int incomingByte; // a variable to read incoming serial data into
void setup() {
Serial.begin(9600); // initialize serial communication
pinMode(ledPin13, OUTPUT);
pinMode(ledPin12, OUTPUT);
pinMode(ledPin11, OUTPUT);
pinMode(ledPin10, OUTPUT);
}
void loop() {
// see if there's incoming serial data:
if (Serial.available() > 0) {
incomingByte = Serial.read(); // read the oldest byte in the serial buffer
//Preform the code to switch on or off the leds
if (incomingByte == '0') {
digitalWrite(ledPin13, HIGH);
}
if (incomingByte == '1') {
digitalWrite(ledPin13, LOW);
}
if (incomingByte == '2') {
digitalWrite(ledPin12, HIGH);
}
if (incomingByte == '3') {
digitalWrite(ledPin12, LOW);
}
}
if (incomingByte == '4') {
digitalWrite(ledPin11, HIGH);
}
if (incomingByte == '5') {
digitalWrite(ledPin11, LOW);
}
if (incomingByte == '7') {
digitalWrite(ledPin12, LOW);
digitalWrite(ledPin11, LOW);
}
if (incomingByte == '6') {
digitalWrite(ledPin12, HIGH);
digitalWrite(ledPin11, HIGH);
}
if (incomingByte == '8') {
digitalWrite(ledPin10, HIGH);
}
if (incomingByte == '9') {
digitalWrite(ledPin10, LOW);
}
if (incomingByte == 'l') {
digitalWrite(ledPin13, HIGH);
digitalWrite(ledPin10, HIGH);
}
if (incomingByte == 'o') {
digitalWrite(ledPin13, LOW);
digitalWrite(ledPin10, LOW);
digitalWrite(ledPin8, LOW);
}
if (incomingByte == 'b') {
digitalWrite(ledPin8, HIGH);
}
}