HI Friends,
I have prepared a board to work stand alone. I am trying to achieve communication between computer and my standalone Arduino. I have attached pics of the USB RS232 converter that I have. My question is how to connect the USB serial to Arduino stanalone. I assumed that TX from USB to RX of ATMEGA and RX from USB to ATMEGA TX would work. I am trying to control 3 LED's from my computer. With the connections above All the LEDs start blinking randomly. Not sure whats wrong. Below is my code.
/*
Author: Suresh Mali
Date: 17 March 2014
Version: 1.0.0
Description: Swicthing lights based on computer input
*/
void setup() {
// initialize serial communication:
Serial.begin(9600);
// initialize the LED pins:
for (int thisPin = 5; thisPin < 8; thisPin++) {
pinMode(thisPin, OUTPUT);
}
}
void loop() {
// read the sensor:
if (Serial.available() > 0) {
int inByte = Serial.read();
switch (inByte) {
case 'r':
digitalWrite(5, HIGH);
digitalWrite(6, LOW);
digitalWrite(7, LOW);
break;
case 'y':
digitalWrite(5, LOW);
digitalWrite(6, HIGH);
digitalWrite(7, LOW);
break;
case 'g':
digitalWrite(5, LOW);
digitalWrite(6, LOW);
digitalWrite(7, HIGH);
break;
case 'o':
digitalWrite(5, LOW);
digitalWrite(6, LOW);
digitalWrite(7, LOW);
break;
}
}
}
Please help. Thanks!