Hi there, for some weird reason, I cant' get into the for loop in the following code
int ledPin = 13; // LED connected to digital pin 13
char c; // receiver bit
int d1, d2, d; // variables
char dest[2]; // destination
int length;
byte dataBuffer[50];
// The setup() method runs once, when the sketch starts
void setup(){
Serial.begin(115200);
// initialize the digital pin as an output:
pinMode(ledPin, OUTPUT);
}
// the loop() method runs over and over again,
// as long as the Arduino has power
void loop(){
// check if data available
while(Serial.available() > 0 && c != byte(4)){
c = Serial.read();
if(c == 'S'){
Serial.println("\n\nsize to be read here !");
int n = 0;
for(int i=2; i=0; i--){
Serial.println(i);
c = Serial.read();
Serial.print(c);
}
Serial.println("Size is");
Serial.println(n);
}
else{
Serial.print(c);
if(c == '1'){
digitalWrite(ledPin,HIGH);
delay(1);}
if(c == '0'){
digitalWrite(ledPin,LOW);
delay(1);}
}
}
if(c == byte(4)){
Serial.println("\nTransmission Done");}
}
I know I enter the first if condition since I print on the serial monitor Serial.println("\n\nsize to be read here !");
Though, for some reason I never get in my for loop...
The purpose of this is to read three bytes containing the size of the frame to be sent (no in this code) if the byte read is 'S'...
Thank you for your help,
Olivier