0% found this document useful (0 votes)
6 views13 pages

IOT PROGRAM

The document provides an introduction to the Arduino IDE, an open-source software for writing and uploading code to Arduino boards, compatible with multiple operating systems and programming languages. It includes several example programs for basic projects such as LED blinking, traffic light control, and interfacing with various sensors and actuators like push buttons, buzzers, and gas sensors. Each program is accompanied by code snippets demonstrating how to implement the respective functionalities.

Uploaded by

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

IOT PROGRAM

The document provides an introduction to the Arduino IDE, an open-source software for writing and uploading code to Arduino boards, compatible with multiple operating systems and programming languages. It includes several example programs for basic projects such as LED blinking, traffic light control, and interfacing with various sensors and actuators like push buttons, buzzers, and gas sensors. Each program is accompanied by code snippets demonstrating how to implement the respective functionalities.

Uploaded by

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

1.

Introduction to Arduino IDE


The Arduino IDE is an open-source software, which is used to write and upload code
to the Arduino boards. The IDE application is suitable for different operating
systems such as Windows, Mac OS X, and Linux. It supports the programming
languages C and C++. Here, IDE stands for Integrated Development Environment.

PROGRAMS:

1. Simple Program LED Blinking


void setup()

pinMode(2,OUTPUT);

void loop() {

digitalWrite(2,HIGH);

delay(1000);

digitalWrite(2,LOW);

delay(1000);}
2. Simple Traffic Light Control Program

Code:

int red = 2 ;

int yellow = 3 ;

int green = 4 ;

void setup()
{

pinMode(red, OUTPUT);

pinMode(yellow, OUTPUT);

pinMode(green, OUTPUT);
}
void loop()

digitalWrite(red, 1);

delay(4000);

digitalWrite(yellow, 1);

delay(1000);

digitalWrite(red, 0);
digitalWrite(yellow, 0);

digitalWrite(green, 1);

delay(5000);

digitalWrite(green, 0);

}
Interfacing Different Types of Sensor and
Actuators
3. Push Button

*NOTE:Resistor- 300Ω
int led = 7,
int pb = 8;
void setup()
{

Serial.begin(9600);

pinMode(led, OUTPUT);

pinMode(pb, INPUT);

}
void loop()
{

int signal = digitalRead(pb);

Serial.println(signal);

if (signal == 1)

digitalWrite(led, 1);

delay(200);

else

digitalWrite(led, 0);

} }
4. Buzzer (Piezo)

*NOTE:Resistor- 300Ω
int buz = 7, int pb = 8;
void setup()
{

Serial.begin(9600);

pinMode(buz, OUTPUT);

pinMode(pb, INPUT);

}
void loop()
{

int signal = digitalRead(pb);

Serial.println(signal);
if (signal == 1)

digitalWrite(buz, 1);

delay(200);

else

digitalWrite(buz, 0);

} }
5. Touch Sensor

int buz = 7, tch = 8;


void setup() {
Serial.begin(9600);
pinMode(buz, OUTPUT);
pinMode(tch, INPUT);
}
void loop()
{

int signal = digitalRead(tch);

Serial.println(signal);
if (signal == 1)

digitalWrite(buz, 1);

delay(200);
}
else
{

digitalWrite(buz, 0);

}
6. LDR Sensor

void setup()
{
pinMode(13, OUTPUT);
Serial.begin(9600);
}
void loop()
{

int ldr = analogRead(A0);

Serial.println(ldr);
delay(100);
if (ldr > 900)

digitalWrite(13, 1);

else

digitalWrite(13, 0);}

}
6. (7 -Segment LED Display )
7. MQ135 Gas Sensor

void setup()
{
Serial.begin(9600);
}
void loop()
{
int val = analogRead(A0);
int air = map(val, 0, 1023, 0, 255);

Serial.print("Air Quality ");

Serial.println(air);
delay(1000);

You might also like