Leds y Servo Motor Control
0:47
Conexiones
| Componente | Conexión en Arduino Uno | Notas |
|---|---|---|
| LED1 | Pin digital 2 → LED1 (+) | Conectar en serie un resistor de 220Ω al ánodo; cátodo a GND. |
| LED2 | Pin digital 3 → LED2 (+) | Conectar en serie un resistor de 220Ω; cátodo a GND. |
| LED3 | Pin digital 4 → LED3 (+) | Conectar en serie un resistor de 220Ω; cátodo a GND. |
| Botón | Pin digital 7 → botón | Usar la resistencia pull-up interna (configurada en el código) y conectar la otra terminal a GND. |
| Servo | Pin digital 9 → señal servo | Alimentar el servo con 5V y GND del Arduino. |
Cpp
#include Servo myServo; const int servoPin = 9; const int ledPins[] = {2, 3, 4}; const int buttonPin = 7; void setup() { // Configurar LEDs como salida y encenderlos permanentemente for (int i = 0; i < 3; i++) { pinMode(ledPins[i], OUTPUT); digitalWrite(ledPins[i], HIGH); } // Configurar botón con resistencia interna pull-up pinMode(buttonPin, INPUT_PULLUP); // Configurar servo myServo.attach(servoPin); // Posición inicial del servo = 0° myServo.write(0); } void loop() { // Si se presiona el botón (estado LOW) if (digitalRead(buttonPin) == LOW) { myServo.write(90); // Girar a la mitad del rango (90°) } else { myServo.write(0); // Volver a posición inicial (0°) } }
Ready.
Reviews
Properties
Properties describe core aspects of the project.
Pricing & Availability
Distributor | Qty 1 |
|---|
Assets
No assets added.
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.