Hi,
I am very new to this and I only know a few about Arduino.
I would like to catch a message from RS232, do some maths with it and light one of the lamp (depending on the result). The lights would be of high power and thus there'll be an external battery.
Am I right to use Arduino, and so which card should I pick?
Very simple delimited serial code for turning the arduino LED on and off using the serial monitor.
//zoomkat 3-5-12 simple delimited ',' string parse
//from serial port input (via serial monitor)
//and print result out serial port
//send on, or off, from the serial monitor to operate LED
int ledPin = 13;
String readString;
void setup() {
Serial.begin(9600);
pinMode(ledPin, OUTPUT);
Serial.println("serial LED on/off test with , delimiter"); // so I can keep track
}
void loop() {
if (Serial.available()) {
char c = Serial.read(); //gets one byte from serial buffer
if (c == ',') {
Serial.println(readString); //prints string to serial port out
//do stuff with the captured readString
if(readString.indexOf("on") >=0)
{
digitalWrite(ledPin, HIGH);
Serial.println("LED ON");
}
if(readString.indexOf("off") >=0)
{
digitalWrite(ledPin, LOW);
Serial.println("LED OFF");
}
readString=""; //clears variable for new input
}
else {
readString += c; //makes the string readString
}
}
}