Project 1 Arduino
Arduino - Making an LED Blink
This is a simple sketch for Arduino that flashes an LED connected to pin 13.
Requirements
To run this script, you must have:
a compatible Arduino board
One LED
A resistor (if necessary to limit the current)
Connecting cables
Connection
Connect the LED to pin 13 on the Arduino board. Be sure to use a resistor (usually 220 ohms) in series with the LED to limit the current and protect the LED.
Instructions
Load the sketch into the Arduino IDE.
Connect the Arduino board to the computer via USB cable.
Select the correct board type and port in the Arduino IDE.
Load the sketch onto the Arduino board.
Observe the LED flashing at regular one-second intervals.
Code
#define LED 13 // LED connected to pin 13
void setup() {
pinMode(LED, OUTPUT); // Set the pin as output
}
void loop() {
digitalWrite(LED, HIGH); // Turn on the LED
delay(1000); // Wait a second
digitalWrite(LED, LOW); // Turn off the LED
delay(1000); // Wait a second
}
License
Questo script è rilasciato sotto la Licenza MIT.
Last updated