0% found this document useful (0 votes)
2 views

Sample Paper -Practical IoT

The document contains a sample question paper with practical programming tasks related to Arduino. Each task includes a specific programming challenge, such as using sensors, controlling LEDs, and displaying messages on an LCD. The document also provides solutions for each task with corresponding code snippets.

Uploaded by

Akansha
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Sample Paper -Practical IoT

The document contains a sample question paper with practical programming tasks related to Arduino. Each task includes a specific programming challenge, such as using sensors, controlling LEDs, and displaying messages on an LCD. The document also provides solutions for each task with corresponding code snippets.

Uploaded by

Akansha
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

SAMPLE QUESTION PAPER

PRACTICAL QUESTIONS
1. Write a program to use TMP (temperature sensor) and sketch the
temperature on the LCD.

2. Write a program to light 5 multiple LEDs in sequence and then in


reverse.

3. Write a program to turn on the LED when there is dark and


automatically turn off the light when there is light already.
4. Write a program to use Piezo and test the sound output.
5. Write a program to sketch “Hello Programmer” on the LCD.
6. Write a program to increase/decrease the speed of blinking of LED
based on the Potentiometer sensor.
7. Write a program to use potentiometer and multimeter and show the
current value from potentiometer to multimeter.
8. Write a program to use the PIR sensor and light up the LED when
the motion of the object is detected in its range.
9. Write a program to move the servo motor based on the value of the
potentiometer.
10. Write a program to take string as input from the Serial monitor and
convert it to lowercase and uppercase.
SOLUTIONS:
Ans 1:

#include <LiquidCrystal.h>

LiquidCrystal lcd(12,11,5,4,3,2);

void setup()

lcd.begin(16,2);

void loop()

int temp = analogRead(A0);

temp = temp * 0.48828125; // converting the analog volt to its temperature equivalent

lcd.setCursor(0,0);

lcd.print("Temperature :");

lcd.setCursor(2,1);

lcd.print(temp);

lcd.print(" ");

lcd.print("C");
lcd.print(" ");

Ans 2:

int ledPins[ ] = {13, 12, 11, 10, 9}; // an array of pin numbers to which LEDs are attached

int pinCount = 5; // the number of pins (i.e. the length of the array)

void setup()

int thisPin =0;

for ( ; thisPin < pinCount; thisPin++)

pinMode(ledPins[thisPin], OUTPUT);

void loop()

for (int thisPin = 0; thisPin < pinCount; thisPin++)

digitalWrite(ledPins[thisPin], HIGH);

delay(500);

digitalWrite(ledPins[thisPin], LOW);
}

for (int thisPin = pinCount - 2; thisPin >= 0; thisPin--)

digitalWrite(ledPins[thisPin], HIGH);

delay(500);

digitalWrite(ledPins[thisPin], LOW);

Ans 3:

int led = 5;

int ldr = A0;

int threshold = 300;

void setup()

{
Serial.begin(9600);

pinMode(led, OUTPUT);

pinMode(ldr,INPUT);

void loop()

int y = analogRead(ldr);

Serial.println(y);

if (y <=threshold)

digitalWrite(led,HIGH);

else

digitalWrite(led,LOW);

delay(200);

Ans 4:
int SPEAKER = 10;

int freq = 50;

void setup()

pinMode(SPEAKER, OUTPUT);

void loop()

freq += 100; // add 100 to freq

if (freq > 8000)

noTone(SPEAKER);

freq = 50;

tone(SPEAKER, freq);

delay(100);

Ans 5:
#include<LiquidCrystal.h>

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup()

lcd.begin(16, 2);

void loop()

lcd.setCursor(0,0);

lcd.print("Hello Programmer");

Ans 6:

int potPin = 2;

int ledPin = 13;

int val = 0;

void setup( )

pinMode(ledPin, OUTPUT);

pinMode(potPin, INPUT);
}

void loop()

val = analogRead(potPin);

digitalWrite(ledPin, HIGH);

delay(val);

digitalWrite(ledPin, LOW);

delay(val);

Ans 7:

int analogPin = A1;

int output;

int value;

void setup()

pinMode(6, OUTPUT);

void loop()

{
output = analogRead(analogPin);

value = map(output,0,1023,0,255);

analogWrite(6,value);

delay(2);

Ans 8:

void setup()

pinMode(3, INPUT);

pinMode(13, OUTPUT);

void loop()

if (digitalRead(3) == HIGH)

Serial.println("Motion Detected");

digitalWrite(13, HIGH);

else
digitalWrite(13, LOW);

delay(10);

Ans 9:

#include <Servo.h>

Servo myservo;

int potpin = 0;

int val;

void setup()

myservo.attach(9);

void loop()

val = analogRead(potpin);

val = map(val, 0, 1023, 0, 180);

myservo.write(val);
delay(15);

Ans 10:
In circuit, only Arduino Board is to be placed.

void setup()

Serial.begin(9600);

while (!Serial); // wait for serial port to connect. Needed for native USB port
only");

Serial.println("\n\nEnter any String and it will be changed to Upper and Lower case:");

Serial.println();

void loop()

if (Serial.available() > 0)

String str = Serial.readString();

Serial.println("The entered string is :\t");

Serial.println(str);

str.toUpperCase();

Serial.println("Uppercase string is :\t");

Serial.println(str);

Serial.println();

Serial.println("Lowercase string is :\t");


str.toLowerCase();

Serial.println(str);

Serial.println();

while(true);

You might also like