You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

25 lines
675 B
C++

int pwmPin = 11; //define output pin, Meergranen output pin is 11
void setup() {
pinMode(pwmPin, OUTPUT); //set pin as output
}
void loop() { // run forever
for(int value = 0; value<=255; value++){ // cycle through 255 values, start at 0. 8 bit output == 255 values
analogWrite(pwmPin, value); // analogWrite simulates smooth sinewave using complex pwm duty cycles
delay(30);
}
delay(30);
// when value == 255, run loop below
for(int value = 255; value>=0; value--){ // each loop substract 1 from value
analogWrite(pwmPin, value); // analogWrite simulates smooth sinewave using complex pwm duty cycles
delay(30);
}
delay(10);
}