Need help with a program

I was wondering if anyone could write a sketch for me?
I need two inputs and two outputs. When an input is taken high the output for that input ramps up to 80% brightness then flashes at 100% brightness then starts at 80% brightness and ramps down to 0%, pauses for 150 milliseconds and starts over and continues in this cycle until the input is taken low again. The entire cycle needs to happen in approx. 1.25 seconds (possibly adjustable).
Could anyone help me?

Could be either Arduino NANO, Seeeduino, or maybe 8 pin pic

Hi NavyDoc
Bellow is sample code for Arduino nano.


void setup() {
  pinMode(13, OUTPUT);      //on board LED(not available PWM)  
  pinMode(5, OUTPUT);       //PWM available pins PWM490Hz:3,9,10,11  PWM980Hz:5,6
  pinMode(4, INPUT_PULLUP); //switch input
}

void loop() {
  while(!digitalRead(4)){                   //while the switch is on:LOW 
    digitalWrite(13, HIGH);
    for (int pwm = 0; pwm < 200; pwm++){    //0%->80% 
      analogWrite(5, pwm);
      delay(2);    
    }

    for (int i = 0; i < 5; i++){            //blink 80%-100%
      analogWrite(5, 256);
      delay(50);
      analogWrite(5, 200);
      delay(50);
    }

    for (int pwm = 200; pwm >= 0; pwm--){   //80%->0%
      analogWrite(5, pwm);
      delay(2);    
    }
    
    digitalWrite(13, LOW);
    delay(150);
  }
}
1 Like

Thank you. I will try this when I get off work today.
Thank you, again for the help