At first make circuit diagram as bellow
Materials:
- Breadboard
- Arduino Uno
- LED
- 220 ohm resistor
- Jumper wires
Aim:
The aim of this experiment is to implement and understand the basic concepts of digital input and output using an Arduino. By connecting an LED to the Arduino and programming it to blink, we can explore how to control digital outputs.
Steps:
-
Connect the breadboard to the Arduino. The Arduino Uno has rows of male pins that fit into the female sockets of the breadboard.
-
Connect the resistor to the breadboard. One leg of the resistor should be placed in any row of the breadboard. The other leg should be placed in a different row.
-
Connect the cathode (short leg) of the LED to the ground (GND) pin of the Arduino. The GND pin is one of the outer pins on the Arduino Uno that has a ground symbol next to it.
-
Connect the resistor to the cathode (short leg) of the LED. Insert one leg of the LED into the same row of the breadboard that the short leg of the resistor is in.
-
Connect the anode (long leg) of the LED to a digital output pin of the Arduino. Digital output pins are any of the pins on the Arduino Uno that are not designated as GND or 3V3. A common pin to use is pin 13. Insert the leg of the LED into the same row of the breadboard that the other leg of the resistor is in.
-
Connect the Arduino to your computer using a USB cable.
-
Write and upload code to the Arduino. Here is a simple code that will blink an LED on and off:
int ledPin = 8; // Define the LED pin
void setup() {
pinMode(ledPin, OUTPUT); // Set the LED pin as an output
}
void loop() {
digitalWrite(ledPin, HIGH); // Turn the LED on
delay(1000); // Wait for 1 second
digitalWrite(ledPin, LOW); // Turn the LED off
delay(1000); // Wait for 1 second
}
-
Open the Arduino IDE software. The Arduino IDE is a free software program that you can use to write and upload code to your Arduino. You can download it from the Arduino website https://www.arduino.cc/en/software.
-
Copy and paste the code into a new sketch. A sketch is a file that contains your Arduino code.
-
Connect your Arduino to your computer using a USB cable.
-
Click the "Verify" button in the Arduino IDE. This will check your code for errors.
-
Click the "Upload" button in the Arduino IDE. This will upload your code to your Arduino.
The LED should start blinking on and off.
0 Comments