int data = 0; int dimLED = 9; void setup() { Serial.begin(9600); pinMode(dimLED, OUTPUT); } void loop() { if(Serial.available()>0){ data = Serial.read(); Serial.println(data); analogWrite(dimLED, data);// set PWM for LED brightness } }