Skip to content

Instantly share code, notes, and snippets.

@cuu
Created October 9, 2022 06:37
Show Gist options
  • Save cuu/0f4932b4e7bb29be034a1c89c4018659 to your computer and use it in GitHub Desktop.
Save cuu/0f4932b4e7bb29be034a1c89c4018659 to your computer and use it in GitHub Desktop.
int ledPin=PA8;
HardwareTimer timer(1);
void setup() {
// put your setup code here, to run once:
pinMode(ledPin,OUTPUT);
digitalWrite(ledPin,LOW);
pinMode(ledPin,PWM);
timer.setPeriod(200);
timer.resume();
}
void loop() {
pinMode(ledPin,PWM);
for(int fadeValue=0;fadeValue<=6553; fadeValue+=200) {
pwmWrite(ledPin,fadeValue);
delay(30);
}
for(int fadeValue= 6553;fadeValue>=0;fadeValue-=200) {
pwmWrite(ledPin,fadeValue);
delay(30);
}
pwmWrite(ledPin,0);
delay(400);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment