Sie sind auf Seite 1von 3

Mechanisms and Robotics Lab

(ME G-511 P)
Instructor In-Charge: Dr. Y. V. D. Rao
BITS Pilani LED Blinking
Hyderabad Campus
How to Blink an LED using Arduino?

Objective:
To turn ON the LED for a second and then turn it OFF for next one
second and repeat.

Components Required:
1. 1 x Breadboard
2. 1 x Arduino UNO
3. 1 x LED
4. 1 x 330ohms Resistor
5. Jumper Wires

BITS Pilani, Hyderabad Campus


int ledPin =2;
void setup() {
// put your setup code here, to run once:
pinMode(ledPin, OUTPUT); //can also be written as pinMode(2, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
digitalWrite(ledPin, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(ledPin, LOW); // turn the LED off by making the voltage LOW
delay(1000);
}

Thank you
BITS Pilani, Hyderabad Campus

Das könnte Ihnen auch gefallen