0% found this document useful (0 votes)
19 views9 pages

IOT File

Uploaded by

yuvraaj.sehgal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views9 pages

IOT File

Uploaded by

yuvraaj.sehgal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 9

PRACTICAL FILE

OF IOT

AMITY UNIVERSITY PUNJAB, MOHALI

SUBMITTED TO: SUBMITTED BY:


Yuvraaj Sehgal
B.Tech CSE(AI & ML)
Section – E(A253175124068)

1
INDEX
1. Write a program to blink internal light with delay in
Arduino board (pg.- 3-4)
2. Write a program to blink led light with delay, which is
connected with Arduino board. (pg.- 5-6)

3. Write a program to blink led light using pushbutton


which are connected with Arduino board. (pg.- 7-9)
4.

2
Q1. Write a program to blink internal light with
delay in Arduino board.

Solution:

// Pin connected to the internal LED on the


Arduino
const int ledPin = 13;

void setup() {
// Initialize the digital pin as an output
pinMode(ledPin, OUTPUT);
}

void loop() {
// Turn the LED on
digitalWrite(ledPin, HIGH);
// Wait for 1 second
delay(1000);
// Turn the LED off
3
digitalWrite(ledPin, LOW);
// Wait for 1 second
delay(1000);
}

Output:

4
Q2. Write a program to blink led light with
delay, which is connected with Arduino board.

Solution:

// Pin connected to the external LED


const int ledPin = 13;

void setup() {
// Initialize the digital pin 13 as an output
pinMode(ledPin, OUTPUT);
}

void loop() {
// Turn the LED on
digitalWrite(ledPin, HIGH);
// Wait for 1 second (1000 milliseconds)
delay(1000);
// Turn the LED off

5
digitalWrite(ledPin, LOW);
// Wait for 1 second (1000 milliseconds)
delay(1000);
}

Output:

6
Q3. Write a program to blink led light using
pushbutton which are connected with Arduino
board.

Solution:
// Pin connected to the LED
int ledPin = 13;
// Pin connected to the pushbutton
int buttonPin = 2;

void setup() {
// Initialize the LED pin as an output
pinMode(ledPin, OUTPUT);
// Initialize the pushbutton pin as an input
pinMode(buttonPin, INPUT);
}

void loop() {

7
// Check if the button is pressed
if (digitalRead(buttonPin) == 1) {
// Blink the LED when button is pressed
digitalWrite(ledPin, HIGH); // Turn the LED
on
}
else {
// Keep the LED off if the button is not
pressed
digitalWrite(ledPin, LOW);
}
}

Output:

8
9

You might also like