I'm trying to control my Arduino via serial input from a computer. I was having problems with getting this to work, so I ran a very basic code as a test. This prints -1 constantly. Am I doing something wrong in the code here, and how might I fix the problem?
void setup() {
Serial.begin(9600);
int Data = 0;
}
void loop() {
while(Serial.available() > 0){
Data = Serial.read();
Serial.print(Data);
}
}