But
if send S2 (controller recive data - 2)

I think some idea about free version X-sim? but not sue
What version work correct?
need check program for arduino DUE
thanks
int led = 13; // select the pin for the LED
int val; // variable to store the data from the serial port
int q;
char bufferArray[20];
void setup() {
pinMode(led,OUTPUT); // declare the LED's pin as output
Serial.begin(9600); // connect to the serial port
}
void loop () {
if (Serial.available() > 9) { //if bytes available in the Serial buffer...
for (q=0; q<8; q++) { // for each byte
bufferArray[q] = Serial.read(); // put into array
}
}
if (bufferArray[0] =='S' ){ // if new bytes have been recieved
val = bufferArray[1]; // store high byte of rpm
}
// if the stored value is a single-digit number, blink the LED that number
if (val > '0' && val <= '9' ) {
val = val - '0'; // convert from character to number
for(int i=0; i<val; i++) {
Serial.println("blink!");
digitalWrite(led,HIGH);
delay(1000);
digitalWrite(led, LOW);
delay(1000);
}
//Serial.println();
}
}
Return to New users start here - FAQ
Users browsing this forum: No registered users and 8 guests