[go: up one dir, main page]

0% found this document useful (0 votes)
22 views25 pages

Iot Problems

The document provides programming exercises to interface different electronic components like LEDs, buzzers, buttons, LDR sensors, LCD displays, and keypads with an Arduino board. The exercises cover basics like blinking LEDs, as well as more complex tasks like LED patterns, fading, and sensor-based control.

Uploaded by

gu ki
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)
22 views25 pages

Iot Problems

The document provides programming exercises to interface different electronic components like LEDs, buzzers, buttons, LDR sensors, LCD displays, and keypads with an Arduino board. The exercises cover basics like blinking LEDs, as well as more complex tasks like LED patterns, fading, and sensor-based control.

Uploaded by

gu ki
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/ 25

1) Write a program to Blink default Light Emitting Diode(LED) on Arduino board with the delay of 2 sec.

2) Write a program to interface LEDs on pin no. 10,11,12,13 and blink alternatively at the delay of 1 sec
3) Write a program to run pattern(s) on LEDs connect at pins 10,11,12,13. Pattern example:

Same as above. Do practice

4) Write a program to interface buzzer with Arduino board to buzz on/off with the delay of 1sec.
5) Write a program to interface LED and Buzzer with Arduino board, so that buzzer is put on whenever LED is on and Buzzer is put off when LED is off
6) Write a program to interface Button and LED, so that LED blinks/glow when button is pressed.
7) Write a program to interface Button, buzzer and LED, whenever the button is pressed the buzzer gives beep for 100ms and LED status is toggled.
8) Write a program to interface LEDs at pins 10,11,12,13 and buttons at pins 7,8. When first time button at pin 7(increment button) is pressed first LED
at pin 10 is switched on, when second time button is pressed the next LED at 11 is switched on. Similarly, when the button at pin 8 (decrement
button) is pressed the LEDs are switched off sequentially
const int led_1=10;
const int led_2=11;
const int led_3=12;
const int led_4=13;

const int incr_btn=7;


const int decr_btn=8;

int led_counter=0;

void setup()
{
pinMode(led_1,OUTPUT);
pinMode(led_2,OUTPUT);
pinMode(led_3,OUTPUT);
pinMode(led_4,OUTPUT);

pinMode(incr_btn,INPUT);
pinMode(decr_btn,INPUT);

//Serial.begin(9600);
}

void loop()
{
if(digitalRead(incr_btn)) // increment counter when PIN 7 is HIGH
{
led_counter++;
//Serial.println(led_counter);
}
if(digitalRead(decr_btn)) // decrement counter when PIN 8 is HIGH
{
led_counter--;
//Serial.println(led_counter);
}

switch(led_counter)
{

case 0:
digitalWrite(led_1,LOW);
digitalWrite(led_2,LOW);
digitalWrite(led_3,LOW);
digitalWrite(led_4,LOW);
break;

case 1:
digitalWrite(led_1,HIGH);
digitalWrite(led_2,LOW);
digitalWrite(led_3,LOW);
digitalWrite(led_4,LOW);
break;

case 2:
digitalWrite(led_1,HIGH);
digitalWrite(led_2,HIGH);
digitalWrite(led_3,LOW);
digitalWrite(led_4,LOW);
break;

case 3:
digitalWrite(led_1,HIGH);
digitalWrite(led_2,HIGH);
digitalWrite(led_3,HIGH);
digitalWrite(led_4,LOW);
break;

case 4:
digitalWrite(led_1,HIGH);
digitalWrite(led_2,HIGH);
digitalWrite(led_3,HIGH);
digitalWrite(led_4,HIGH);
break;

default:
digitalWrite(led_1,LOW);
digitalWrite(led_2,HIGH);
digitalWrite(led_3,HIGH);
digitalWrite(led_4,LOW);
break;
}

delay(100);

}
9) Write a program to interface LEDs at pins 10,11,12,13 and button at pins 7. The press of button changes the pattern of LED glow. (considering four
patterns of LED glow)

int LED1=10;
int LED2=11;
int LED3=12;
int LED4=13;
int button=9;
int p=0;
int buttonState=0;
void setup()
{
pinMode(LED1, OUTPUT);
pinMode(LED2, OUTPUT);
pinMode(LED3, OUTPUT);
pinMode(LED4, OUTPUT);
pinMode(button, INPUT);

void loop()
{
buttonState = digitalRead(9);
if (buttonState==HIGH)
{
p++;
delay(1000);
}
if (p==1)
{
digitalWrite(LED1,HIGH);
digitalWrite(LED2,LOW);
digitalWrite(LED3,LOW);
digitalWrite(LED4,LOW);
delay(1000);

digitalWrite(LED1,LOW);
digitalWrite(LED2,HIGH);
digitalWrite(LED3,LOW);
digitalWrite(LED4,LOW);
delay(1000);

digitalWrite(LED1,LOW);
digitalWrite(LED2,LOW);
digitalWrite(LED3,HIGH);
digitalWrite(LED4,LOW);
delay(1000);

digitalWrite(LED1,LOW);
digitalWrite(LED2,LOW);
digitalWrite(LED3,LOW);
digitalWrite(LED4,HIGH);
delay(1000);
}
if (p==2)
{
digitalWrite(LED1,LOW);
digitalWrite(LED2,LOW);
digitalWrite(LED3,LOW);
digitalWrite(LED4,HIGH);
delay(1000);

digitalWrite(LED1,LOW);
digitalWrite(LED2,LOW);
digitalWrite(LED3,HIGH);
digitalWrite(LED4,LOW);
delay(1000);
digitalWrite(LED1,LOW);
digitalWrite(LED2,HIGH);
digitalWrite(LED3,LOW);
digitalWrite(LED4,LOW);
delay(1000);

digitalWrite(LED1,HIGH);
digitalWrite(LED2,LOW);
digitalWrite(LED3,LOW);
digitalWrite(LED4,LOW);
delay(1000);

}
if (p==3)
{
digitalWrite(LED1,HIGH);
digitalWrite(LED2,HIGH);
digitalWrite(LED3,LOW);
digitalWrite(LED4,LOW);
delay(1000);

digitalWrite(LED1,LOW);
digitalWrite(LED2,HIGH);
digitalWrite(LED3,HIGH);
digitalWrite(LED4,LOW);
delay(1000);

digitalWrite(LED1,LOW);
digitalWrite(LED2,LOW);
digitalWrite(LED3,HIGH);
digitalWrite(LED4,HIGH);
delay(1000);

digitalWrite(LED1,HIGH);
digitalWrite(LED2,LOW);
digitalWrite(LED3,LOW);
digitalWrite(LED4,HIGH);
delay(1000);

if (p==4)
{
digitalWrite(LED1,HIGH);
digitalWrite(LED2,HIGH);
digitalWrite(LED3,HIGH);
digitalWrite(LED4,HIGH);
delay(500);

digitalWrite(LED1,LOW);
digitalWrite(LED2,LOW);
digitalWrite(LED3,LOW);
digitalWrite(LED4,LOW);
delay(1000);

digitalWrite(LED1,HIGH);
digitalWrite(LED2,HIGH);
digitalWrite(LED3,HIGH);
digitalWrite(LED4,HIGH);
delay(1000);

digitalWrite(LED1,LOW);
digitalWrite(LED2,LOW);
digitalWrite(LED3,LOW);
digitalWrite(LED4,LOW);
delay(1000);

p=0; //reset
}

}
10) Write a program to interface Light Dependent Resistor (LDR) and display the values read on the Serial monitor after delay of 2 seconds each.
11) Write a program to interface Light Dependent Resistor (LDR) and LED with Arduino board. Whenever there is sufficient light falls on LDR the LED is
off and when there is dark around LDR the LED is put on.]
12) Write a program to interface LEDs at any two PWM pins and exhibit LED fading.
13) Write a program to interface LED at PWM pin and LDR, in such a way that when the light intensity falling on LDR rises the LED glow should be
reduced and after a threshold value the LED should be put off. (representing smart street light concept)
14) Write a program to interface one LED at any PWM pins and button, to exhibit LED fading at the click of button
15) Write a program to interface any analog (pollution) sensor and LED ,so that LED turns ON when sensor crosses threshold value and display the
values read on Serial monitor
16) Write a program to interface LCD with Arduino board and display ‘Hello world’ on it
17) Write a program to interface keypad with Arduino board and display the key pressed on Serial monitor.

You might also like