Sending commands to Arduino

I did some searching and i can't seem to find any good answer.

Is there a way to Send 4 characters to the Arduino reliably?

I can get one character to send all the time, but if i try two or more, i get the first character and three 'ÿ'

Although i could just send letters and numbers that limits the number of commands a lot more then if i can send multiple characters.

I could really use some help.

Thanks Kevin

Can you post your code and how you communicate with arduino?

You should be able to send long strings to Arduino from a PC reliably without a problem.

Are you shure your PC's serial port is configured correct ?

I was just playing with something similar this afternoon (an upcoming project I have bubbling around in my head)

The code I boiled it down to was this:

void setup()

void loop() {
  if(Serial.available() == 4)

It just displays the input so far but it might help?


Is there a way to Send 4 characters to the Arduino reliably?

Sending to the Arduino from where? PC? Mac? Linux? Could you post the code that’s doing the sending?

int led0 = 2;
int led1 = 3;
int led2 = 4;
int led3 = 6;
int led4 = 8;
int led5 = 10;
int led6 = 12;
int led7 = 13;

void setup() {
  pinMode(led0, OUTPUT);  
  pinMode(led1, OUTPUT);
  pinMode(led2, OUTPUT);
  pinMode(led3, OUTPUT);
  pinMode(led4, OUTPUT);
  pinMode(led5, OUTPUT);
  pinMode(led6, OUTPUT);
  pinMode(led7, OUTPUT);


void loop() {
  int val1=0;
  int val2=0;
  int val3=0;
  int val4=0;
  if (Serial.available()) {
     val1 =;
     val2 =;
     val3 =;
     val4 =;

void flash(int led, int wait) {

I am either sending the commands from the Ardino serial console, or via pyserail using the python console I am using ubunto 8.10


The reason why this code doesn't work is you are not waiting until you have received enough characters. It waits for one and then reads it and then reads the next three without there being anything in the buffer.

Change if (Serial.available()) { to if (Serial.available() > 3) {


That worked