corrección led_pwm2

This commit is contained in:
jp.av.dev 2022-04-04 15:22:18 -04:00
parent 4956fda212
commit e59696a8ee
5 changed files with 68 additions and 73 deletions

View File

@ -15,15 +15,15 @@ Implementaciones :
- [Buzzers/Speakers](./buzzer/README.md)
- [PWM](./pwm/README.md)
- [Leds](./leds/README.md)
- [Led Dimmer](./leds/dimmer_led/dimmer_led.ino)
- [Leds PWM](./leds/led_pwm/led_pwm.ino)
- [Led PWM](./leds/led_pwm/led_pwm.ino)
- [Led PWM2](./leds/led_pwm2/led_pwm2.ino)
- [Leds PWM 1](./leds/leds_pwm/leds_pwm.ino)
- [Leds PwM 2](./leds/leds_pwm2/leds_pwm2.ino)
- [Potenciomentro y Led](./leds/potenciomentro_led/potenciomentro_led.ino)
- [Led Dimmer](./leds/dimmer_led/dimmer_led.ino)
- [RGB](./leds/rgb/rgb.ino)
- [RGB 2](./leds/rgb2/rgb2.ino)
- [RGB 3](./leds/rgb3/rgb3.ino)
- [Semaforo](./leds/semaforo/semaforo.ino)
- [Serial Leds](./leds/serial_leds/serial_leds.ino)
- [Sensores](./sensores/README.md)
- Temperatura y Humedad

View File

@ -1,14 +1,13 @@
## Leds
- [Led Dimmer](./dimmer_led/dimmer_led.ino)
- [Leds PWM](./led_pwm/led_pwm.ino)
- [Led PWM](./led_pwm/led_pwm.ino)
- [Led PWM 2](./led_pwm2/led_pwm2.ino)
- [Leds PWM 1](./leds_pwm/leds_pwm.ino)
- [Leds PwM 2](./leds_pwm2/leds_pwm2.ino)
- [Potenciomentro y Led](./potenciomentro_led/potenciomentro_led.ino)
- [Led Dimmer](./dimmer_led/dimmer_led.ino)
- [RGB](./rgb/rgb.ino)
- [RGB 2](./rgb2/rgb2.ino)
- [RGB 3](./rgb3/rgb3.ino)
- [Semaforo](./semaforo/semaforo.ino)
- [Serial Leds](./serial_leds/serial_leds.ino)

13
leds/led_pwm2/led_pwm2.ino Executable file
View File

@ -0,0 +1,13 @@
// La functión setup corre solo una vez al encender/reiniciar la placa
void setup() {
// Inicializar pin digital como output.
pinMode(10, OUTPUT);
}
// La función loop corre una y otra vez, por siemre
void loop() {
for (int i = 0; i <= 255; i++) {
analogWrite(10, i);
delay(10);
}
}

View File

@ -1,15 +0,0 @@
// the setup function runs once when you press reset or power the board
void setup() {
// initialize digital pin LED_BUILTIN as an output.
pinMode(10, OUTPUT);
}
// the loop function runs over and over again forever
void loop() {
for (int i = 0; i <= 255; i++) {
analogWrite(10, i);
delay(10);
}
}

View File

@ -1,42 +1,40 @@
void setup() {
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
Serial.begin(9600);
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
Serial.begin(9600);
}
void ciclo1() {
int i=0;
while (i < 5) {
digitalWrite(3, LOW);
digitalWrite(2, HIGH);
delay(500);
digitalWrite(2, LOW);
digitalWrite(3, HIGH);
delay(500);
++i;
}
apagaLeds();
int i=0;
while (i < 5) {
digitalWrite(3, LOW);
digitalWrite(2, HIGH);
delay(500);
digitalWrite(2, LOW);
digitalWrite(3, HIGH);
delay(500);
++i;
}
apagaLeds();
}
void ciclo2() {
int j=0;
while (j < 5) {
digitalWrite(3, LOW);
digitalWrite(2, HIGH);
delay(50);
digitalWrite(2, LOW);
digitalWrite(2, HIGH);
delay(50);
digitalWrite(2, LOW);
digitalWrite(3, HIGH);
delay(50);
digitalWrite(3, LOW);
digitalWrite(3, HIGH);
++j;
}
apagaLeds();
int j=0;
while (j < 5) {
digitalWrite(3, LOW);
digitalWrite(2, HIGH);
delay(50);
digitalWrite(2, LOW);
digitalWrite(2, HIGH);
delay(50);
digitalWrite(2, LOW);
digitalWrite(3, HIGH);
delay(50);
digitalWrite(3, LOW);
digitalWrite(3, HIGH);
++j;
}
apagaLeds();
}
void apagaLeds() {
@ -45,22 +43,22 @@ void apagaLeds() {
}
void loop() {
int serialCom;
if (Serial.available() > 0) {
serialCom = Serial.read();
Serial.print("Valor Recibido : ");
Serial.println(serialCom);
switch (serialCom) {
case 49:
ciclo1();
break;
case 50:
ciclo2();
break;
default:
apagaLeds();
}
delay(100);
Serial.read();
}
}
int serialCom;
if (Serial.available() > 0) {
serialCom = Serial.read();
Serial.print("Valor Recibido : ");
Serial.println(serialCom);
switch (serialCom) {
case 49:
ciclo1();
break;
case 50:
ciclo2();
break;
default:
apagaLeds();
}
delay(100);
Serial.read();
}
}