Arduino Uno Programacion Ejemplos Apr 2026
void setup() myservo.attach(9);
Components: LED, 220Ω resistor. Connect to pin 9 (PWM-capable).
void loop() unsigned long currentMillis = millis();
int ledPin = 9; int brightness = 0; int fadeAmount = 5; void setup() pinMode(ledPin, OUTPUT); arduino uno programacion ejemplos
Components: 10kΩ potentiometer. Connect middle pin to A0, outer pins to 5V and GND.
void loop() buttonState = digitalRead(buttonPin);
| Library | Purpose | |---------|---------| | LiquidCrystal.h | Control LCD displays (16x2, 20x4) | | Servo.h | Control up to 12 servos | | Stepper.h | Control stepper motors | | DHT.h | Read temperature/humidity sensors | | SPI.h / Wire.h | SPI and I2C communication | 6. Debugging and Serial Communication The Serial Monitor (Tools → Serial Monitor) is essential for debugging. void setup() myservo
void loop() for (pos = 0; pos <= 180; pos++) myservo.write(pos); delay(15);
void loop() Serial.print("Value: "); Serial.println(analogRead(A0)); delay(500);
#include <Servo.h> Servo myservo; int pos = 0; Connect middle pin to A0, outer pins to 5V and GND
if (currentMillis - previousMillis >= interval) previousMillis = currentMillis; ledState = !ledState; digitalWrite(ledPin, ledState);
Avoids delay() to allow other tasks to run simultaneously.