I was trying to communicate with my arduino uno over the serial connection from the USB. Connecting to it is usually not a problem, but what buggs me is the first transaction of the data... No matter with what I do it, java code or the serial monitor which comes with the IDE, I always have the problem that usually only one Byte is being transfered or received from the Arduino. What could be the problem? Is it just a bug and I have to live with it or can this somehow be fixed?
My Arduino Code:
#include "RGBdriver.h"
#define CLK 10
#define DIN 11
RGBdriver driver(CLK, DIN);
byte red = 0;
byte green = 0;
byte blue = 0;
byte newRed = 0;
byte newGreen = 0;
byte newBlue = 255;
void setup() {
Serial.begin(9600);
}
void loop() {
if (Serial.available() >= 3) {
newRed = Serial.read();
newGreen = Serial.read();
newBlue = Serial.read();
}
if ((red != newRed) || (green != newGreen) || (blue != newBlue)) {
red = newRed;
green = newGreen;
blue = newBlue;
driver.begin();
driver.SetColor(red, green, blue);
driver.end();
}
}