const int fan = 13; // the pin that the LED is attached to int input; // a variable to read incoming serial data into int cislo = 20; char buffer[4]; void setup() { // initialize serial communication: Serial.begin(9600); // initialize the LED pin as an output: pinMode(fan, OUTPUT); } void loop() { if (cislo < 999) { digitalWrite(fan, HIGH); delay(20); } digitalWrite(fan, LOW); delay(cislo); if ( Serial.available() >= 3 ) { buffer[0] = Serial.read(); buffer[1] = Serial.read(); buffer[2] = Serial.read(); buffer[3] = '\0'; cislo = atoi(buffer); Serial.print("I received: "); Serial.println(cislo, DEC); } }