|
||
---|---|---|
.. | ||
pwm.ino | ||
README.md |
PWM
Pulse Width Modulation / Modulación por ancho de pulso
Placa | Pines PWM | Frecuencia PWM |
---|---|---|
Uno, Nano, Mini | 3, 5, 6, 10, 11 | 490Hz (pines 5 y 6:980 Hz) |
Mega | 2 -13, 44-46 | 490Hz (pines 4 y 13:980 Hz) |
Micro | 3, 5, 6, 9, 10, 11, 13 | 490Hz (pines 3 y 11:980 Hz) |
PWM pin 9
#define LED 9
void setup() {
pinMode(LED, OUTPUT);
}
void loop() {
for (byte i=20; i<255; i++) {
analogWrite(LED, i);
delay(5);
}
for (byte i=255; i>20; i--) {
analogWrite(LED, i);
delay(5);
}
}