Solar-Powered IoT Sensor Design
0:29
pinMode(botonb, INPUT):) en lugar de punto y coma (;).if-else para el LEDif se repite la lectura de estado = digitalRead(boton); justo antes del else, lo cual provoca error de sintaxis. Además, ese código no es necesario, ya que la lectura ya se realizó antes del bloque if.elseelse del segundo if se controla el LED en lugar del buzzer.loop() no es la adecuada.Cpp
#define led 8 #define boton 7 #define buzzer 9 #define botonb 10 int estado; void setup(){ pinMode(led, OUTPUT); pinMode(boton, INPUT); pinMode(buzzer, OUTPUT); pinMode(botonb, INPUT); } void loop(){ // Control para el LED estado = digitalRead(boton); if (estado == HIGH) { digitalWrite(led, HIGH); } else { digitalWrite(led, LOW); } // Control para el buzzer estado = digitalRead(botonb); if (estado == HIGH) { digitalWrite(buzzer, HIGH); } else { digitalWrite(buzzer, LOW); } }
pinMode(botonb, INPUT): por pinMode(botonb, INPUT);estado=digitalRead(boton); en el bloque del LED.else del segundo bloque para controlar el buzzer (digitalWrite(buzzer, LOW);) en lugar de controlar el LED.loop() para que ambas secciones sean independientes y correctas.Ready.
Reviews
Original Bronze TARDIS
Properties
Properties describe core aspects of the project.
Pricing & Availability
Distributor | Qty 1 |
|---|
Controls
Welcome 👋
Flux helps you build PCBs faster with an AI teammate!
Create your account to collaborate, stay updated, fork your own version, and get instant answers from our AI agent.