int ledpwm = 8;//pinout of the attiny44 int buttonPin = 3; int i = 0;//variable that will make the work cycle increase int button = 0; void setup(){ pinMode(buttonPin,INPUT); pinMode(ledpwm,OUTPUT); } void loop(){ button = digitalRead(buttonPin); if (button == LOW){ for(i = 0; i <= 255 ; i++){ analogWrite(ledpwm,i); analogWrite(5,255-i); delay(25); } for(i = 255; i>= 0 ; i--){ analogWrite(ledpwm,i); analogWrite(5,255-i); delay(25); } } else { digitalWrite(ledpwm, LOW); // turn the LED off by making the voltage LOW } }