int in = 0; // Variable to store the desired value int pinOutLed = 9; int pwm = 0; void setup() { // This executes once Serial.begin(9600); // Initialize serial port pinMode(pinOutLed, OUTPUT); // Prepare output pin } void loop() { // This loops continuously while(Serial.available() > 0){ // Check if there's data in = Serial.read(); // Read said data into the variable "in" if (in == '+'){ if(pwm < 256){ pwm = pwm + 10; } analogWrite(pinOutLed, pwm); } else if(in == '-'){ if(pwm > -1){ pwm = pwm - 10; } analogWrite(pinOutLed, pwm); } } }