Programming IoT with Arduino
Complete IoT Textbook โ 10 Chapters
From blinking LEDs to cloud-connected smart systems โ master Arduino, sensors, actuators, wireless communication, and IoT cloud platforms in one book.
โฑ๏ธ 50+ hrs total | ๐ฏ Arduino + ESP8266 + Cloud | ๐ฐ โน6โ20 LPA Embedded/IoT | ๐ฅ๏ธ Smart India Hackathon Ready
๐ผ Jobs this unlocks: Embedded Developer (โน6โ10 LPA) | IoT Engineer (โน8โ15 LPA) | Firmware Developer (โน10โ20 LPA)
LCD Interfacing with Arduino Uno
๐ฅ๏ธ Every Display Around You Started with an LCD
ATM machines, railway ticket counters, petrol pump meters, weighing scales at kirana shops โ they all use LCD displays. The 16ร2 LCD is like the "sabse pehla output device" for Arduino. Think of it as a TV remote's display โ small, simple, but powerful enough to show you what matters.
LCD = Jugaad Display! With just โน80 and 6 wires, you can make Arduino talk to you. By the end of this chapter, you'll display custom messages, scrolling text, and even create your own characters like โค๏ธ on a tiny screen.
1.1 LCD Pin Details โ All 16 Pins Explained
A standard 16ร2 LCD module (based on the HD44780 controller) has 16 pins. Understanding each pin is crucial before wiring.
| Pin # | Name | Function |
|---|---|---|
| 1 | VSS | Ground (0V) |
| 2 | VDD | Power Supply (+5V) |
| 3 | V0 | Contrast Adjustment (connect to potentiometer) |
| 4 | RS | Register Select: 0=Command, 1=Data |
| 5 | RW | Read/Write: 0=Write, 1=Read (usually GND) |
| 6 | EN | Enable: Latches data on falling edge |
| 7 | D0 | Data Bit 0 (not used in 4-bit mode) |
| 8 | D1 | Data Bit 1 (not used in 4-bit mode) |
| 9 | D2 | Data Bit 2 (not used in 4-bit mode) |
| 10 | D3 | Data Bit 3 (not used in 4-bit mode) |
| 11 | D4 | Data Bit 4 |
| 12 | D5 | Data Bit 5 |
| 13 | D6 | Data Bit 6 |
| 14 | D7 | Data Bit 7 |
| 15 | A (LED+) | Backlight Anode (+5V through 220ฮฉ resistor) |
| 16 | K (LED-) | Backlight Cathode (GND) |
1.2 Interfacing 16ร2 LCD with Arduino (4-bit Mode)
In 4-bit mode, we only use pins D4โD7, saving 4 Arduino pins. This is the most common wiring method.
Connection Table
| LCD Pin | Arduino Pin | Purpose |
|---|---|---|
| VSS (1) | GND | Ground |
| VDD (2) | 5V | Power |
| V0 (3) | Potentiometer Wiper | Contrast control |
| RS (4) | D12 | Register Select |
| RW (5) | GND | Write mode (always) |
| EN (6) | D11 | Enable pulse |
| D4 (11) | D5 | Data bit 4 |
| D5 (12) | D4 | Data bit 5 |
| D6 (13) | D3 | Data bit 6 |
| D7 (14) | D2 | Data bit 7 |
| A (15) | 5V via 220ฮฉ | Backlight ON |
| K (16) | GND | Backlight GND |
1.3 LiquidCrystal Library Functions
| Function | Description | Example |
|---|---|---|
LiquidCrystal(rs,en,d4,d5,d6,d7) | Constructor โ define pins | LiquidCrystal lcd(12,11,5,4,3,2) |
lcd.begin(cols, rows) | Initialize LCD size | lcd.begin(16, 2) |
lcd.print(data) | Print text/number at cursor | lcd.print("Hello") |
lcd.setCursor(col, row) | Move cursor (0-indexed) | lcd.setCursor(0, 1) |
lcd.clear() | Clear screen, cursor to 0,0 | lcd.clear() |
lcd.scrollDisplayLeft() | Scroll entire display left | Use in loop for marquee |
lcd.scrollDisplayRight() | Scroll entire display right | Reverse marquee |
lcd.blink() | Blinking block cursor | Shows cursor position |
lcd.noBlink() | Stop blinking cursor | Hide cursor |
lcd.createChar(num, data) | Create custom 5ร8 char | Max 8 custom chars (0โ7) |
1.4 Arduino Code โ Hello World on LCD
Arduino // Program: Display "Hello World!" on 16x2 LCD // Board: Arduino Uno // Connection: 4-bit mode (RS=12, EN=11, D4=5, D5=4, D6=3, D7=2) #include <LiquidCrystal.h> // Initialize LCD: LiquidCrystal(RS, EN, D4, D5, D6, D7) LiquidCrystal lcd(12, 11, 5, 4, 3, 2); void setup() { lcd.begin(16, 2); // Set LCD to 16 columns, 2 rows lcd.setCursor(0, 0); // Move cursor to column 0, row 0 lcd.print("Hello World!"); // Print on first line lcd.setCursor(0, 1); // Move cursor to second line lcd.print("Arduino IoT"); // Print on second line } void loop() { // Nothing to repeat โ static display }
1.5 Custom Character Display โ createChar()
The LCD can store up to 8 custom characters (numbered 0โ7). Each character is a 5ร8 pixel grid defined by a byte array.
Arduino // Program: Display custom heart character on LCD #include <LiquidCrystal.h> LiquidCrystal lcd(12, 11, 5, 4, 3, 2); // Define heart character as byte array byte heart[8] = { 0b01010, // Row 0: .#.#. 0b11111, // Row 1: ##### 0b11111, // Row 2: ##### 0b11111, // Row 3: ##### 0b01110, // Row 4: .###. 0b00100, // Row 5: ..#.. 0b00000, // Row 6: .....(blank) 0b00000 // Row 7: .....(blank) }; void setup() { lcd.begin(16, 2); lcd.createChar(0, heart); // Store heart at position 0 lcd.setCursor(0, 0); lcd.print("I "); lcd.write(byte(0)); // Display custom character 0 (heart) lcd.print(" Arduino!"); } void loop() {}
1.6 Worked Examples
Example 1: Display Your Name
Arduino #include <LiquidCrystal.h> LiquidCrystal lcd(12, 11, 5, 4, 3, 2); void setup() { lcd.begin(16, 2); lcd.print("Name: Rahul"); lcd.setCursor(0, 1); lcd.print("Roll: 101"); } void loop() {}
Example 2: Counter 0โ99
Arduino #include <LiquidCrystal.h> LiquidCrystal lcd(12, 11, 5, 4, 3, 2); void setup() { lcd.begin(16, 2); } void loop() { for (int i = 0; i < 100; i++) { lcd.clear(); lcd.print("Count: "); lcd.print(i); delay(500); } }
Example 3: Scrolling Marquee
Arduino #include <LiquidCrystal.h> LiquidCrystal lcd(12, 11, 5, 4, 3, 2); void setup() { lcd.begin(16, 2); lcd.print(" Welcome to EduArtha IoT Lab! "); } void loop() { lcd.scrollDisplayLeft(); // Shift text left by 1 position delay(300); // Speed of scrolling }
Example 4: Temperature Display Format
Arduino #include <LiquidCrystal.h> LiquidCrystal lcd(12, 11, 5, 4, 3, 2); byte degreeSymbol[8] = {0x06,0x09,0x09,0x06,0x00,0x00,0x00,0x00}; void setup() { lcd.begin(16, 2); lcd.createChar(0, degreeSymbol); lcd.print("Temp: 32"); lcd.write(byte(0)); lcd.print("C"); lcd.setCursor(0, 1); lcd.print("Humidity: 65%"); } void loop() {}
Example 5: Custom Heart + Smiley
Arduino #include <LiquidCrystal.h> LiquidCrystal lcd(12, 11, 5, 4, 3, 2); byte heart[8] = {0x00,0x0A,0x1F,0x1F,0x0E,0x04,0x00,0x00}; byte smiley[8] = {0x00,0x0A,0x0A,0x00,0x11,0x0E,0x00,0x00}; void setup() { lcd.begin(16, 2); lcd.createChar(0, heart); lcd.createChar(1, smiley); lcd.write(byte(0)); lcd.print(" I love IoT "); lcd.write(byte(1)); } void loop() {}
Example 6: Blinking Cursor
Arduino #include <LiquidCrystal.h> LiquidCrystal lcd(12, 11, 5, 4, 3, 2); void setup() { lcd.begin(16, 2); lcd.print("Enter PIN:"); lcd.setCursor(0, 1); lcd.blink(); // Show blinking block cursor } void loop() {}
Example 7: Two-Line Message
Arduino #include <LiquidCrystal.h> LiquidCrystal lcd(12, 11, 5, 4, 3, 2); void setup() { lcd.begin(16, 2); lcd.setCursor(2, 0); lcd.print("Jai Hind!"); lcd.setCursor(0, 1); lcd.print("Bharat Mata Ki"); } void loop() {}
Example 8: Right-to-Left Scroll
Arduino #include <LiquidCrystal.h> LiquidCrystal lcd(12, 11, 5, 4, 3, 2); void setup() { lcd.begin(16, 2); lcd.setCursor(0, 0); lcd.print("Scrolling Right"); } void loop() { lcd.scrollDisplayRight(); delay(400); }
Example 9: Display Analog Reading
Arduino #include <LiquidCrystal.h> LiquidCrystal lcd(12, 11, 5, 4, 3, 2); void setup() { lcd.begin(16, 2); } void loop() { int val = analogRead(A0); // Read pot/sensor on A0 lcd.clear(); lcd.print("Analog: "); lcd.print(val); // 0-1023 lcd.setCursor(0, 1); lcd.print("Volts: "); lcd.print(val * 5.0 / 1023, 2); // Convert to voltage delay(500); }
Example 10: Simple LCD Menu
Arduino #include <LiquidCrystal.h> LiquidCrystal lcd(12, 11, 5, 4, 3, 2); int btnPin = 7; int menu = 0; void setup() { lcd.begin(16, 2); pinMode(btnPin, INPUT_PULLUP); showMenu(); } void loop() { if (digitalRead(btnPin) == LOW) { menu = (menu + 1) % 3; showMenu(); delay(300); // Debounce } } void showMenu() { lcd.clear(); lcd.print("> Menu Option:"); lcd.setCursor(0, 1); if (menu == 0) lcd.print("1. Read Temp"); else if (menu == 1) lcd.print("2. Read Light"); else lcd.print("3. Motor ON"); }
lcd.begin(16,2) in setup. (4) Backlight not connected โ check A and K pins.
1.7 MCQs โ Chapter 1 (20 Questions)
How many pins does a standard 16ร2 LCD module have?
- 8
- 14
- 16
- 20
What is the function of pin V0 on the LCD?
- Power supply
- Contrast adjustment
- Data transmission
- Backlight control
In 4-bit mode, which data pins of the LCD are used?
- D0โD3
- D4โD7
- D0โD7
- D2โD5
What does the RS pin on the LCD control?
- Reset the display
- Select between command and data mode
- Control the refresh speed
- Enable the backlight
Which function initializes the LCD dimensions?
- lcd.init(16,2)
- lcd.start(16,2)
- lcd.begin(16,2)
- lcd.setup(16,2)
What is the maximum number of custom characters you can create on a 16ร2 LCD?
- 4
- 8
- 16
- 32
What is the pixel grid size for each custom character on a 16ร2 LCD?
- 8ร8
- 5ร7
- 5ร8
- 7ร5
Why is the RW pin usually connected to GND?
- To save power
- Because we only write to the LCD, never read from it
- It doesn't work otherwise
- To increase speed
Which function moves the cursor to column 5, row 1?
- lcd.setCursor(1, 5)
- lcd.setCursor(5, 1)
- lcd.moveTo(5, 1)
- lcd.goto(5, 1)
What happens when you call lcd.clear()?
- Only the first line is cleared
- The backlight turns off
- All text is erased and cursor moves to position (0,0)
- The LCD resets completely
How many Arduino digital pins are needed for LCD in 4-bit mode (excluding power)?
- 4
- 6
- 8
- 10
What is the purpose of the EN (Enable) pin?
- Enables the backlight
- Latches data on the falling edge of a pulse
- Enables write mode
- Enables the power supply
Which resistor value is typically used with the LCD backlight (pin A)?
- 10ฮฉ
- 100ฮฉ
- 220ฮฉ
- 10kฮฉ
Which library is used for basic LCD control in Arduino?
- LCD.h
- LiquidCrystal.h
- Display.h
- HD44780.h
What controller chip does the standard 16ร2 LCD use?
- ATmega328P
- HD44780
- ESP8266
- MAX7219
To display the byte stored at custom character position 0, which function is used?
- lcd.print(0)
- lcd.display(0)
- lcd.write(byte(0))
- lcd.show(0)
What does lcd.scrollDisplayLeft() do?
- Moves the cursor left
- Shifts the entire display content one position to the left
- Erases the leftmost character
- Rotates the display 90 degrees
How many total characters can a 16ร2 LCD display at once?
- 16
- 24
- 32
- 64
If you want to display text starting from the 3rd column of the 2nd row, which call do you use?
- lcd.setCursor(3, 2)
- lcd.setCursor(2, 1)
- lcd.setCursor(3, 1)
- lcd.setCursor(2, 2)
What advantage does 4-bit mode have over 8-bit mode?
- Faster data transfer
- Uses fewer Arduino pins (6 instead of 10)
- Better contrast
- Supports more characters
LDR, Ultrasonic & IR Sensor Interfacing
๐๏ธ Sensors = Arduino Ki Aankhein Aur Kaan
Without sensors, Arduino is blind and deaf โ it can't sense the world. An LDR detects light (street lights that auto-ON at night), an ultrasonic sensor measures distance (parking sensors in cars), and an IR sensor detects objects (automatic doors at malls). These three sensors are the foundation of every IoT project.
Analogy: Think of sensors as your body's senses โ LDR is your eyes (light), ultrasonic is your ears (echo/sonar), IR is your touch (proximity detection).
2.1 LDR (Light Dependent Resistor)
An LDR's resistance changes with light: bright light โ low resistance (~1kฮฉ), dark โ high resistance (~10Mฮฉ). We use a voltage divider circuit to convert this resistance change into a voltage that Arduino can read via analogRead().
Street Light Automation โ Full Code
Arduino // Program: Automatic Street Light using LDR // When dark (LDR value < threshold) โ LED ON // When bright (LDR value >= threshold) โ LED OFF int ldrPin = A0; // LDR connected to analog pin A0 int ledPin = 13; // LED connected to digital pin 13 int threshold = 500; // Adjust based on your environment void setup() { pinMode(ledPin, OUTPUT); Serial.begin(9600); } void loop() { int ldrValue = analogRead(ldrPin); // Read LDR (0-1023) Serial.print("LDR Value: "); Serial.println(ldrValue); if (ldrValue < threshold) { // Dark condition digitalWrite(ledPin, HIGH); // Turn ON street light Serial.println("STATUS: Dark โ LED ON"); } else { // Bright condition digitalWrite(ledPin, LOW); // Turn OFF street light Serial.println("STATUS: Bright โ LED OFF"); } delay(500); }
2.2 Ultrasonic Sensor (HC-SR04)
The HC-SR04 sends an ultrasonic pulse (40kHz) and measures the time it takes for the echo to return. Distance is calculated using: distance = (time ร 0.034) / 2 (speed of sound โ 340 m/s).
| Pin | Function | Arduino Connection |
|---|---|---|
| VCC | Power (+5V) | 5V |
| Trig | Trigger pulse input | D9 |
| Echo | Echo pulse output | D10 |
| GND | Ground | GND |
Distance Measurement โ Full Code
Arduino // Program: Measure distance using HC-SR04 Ultrasonic Sensor // Formula: distance = (duration * 0.034) / 2 const int trigPin = 9; // Trigger pin const int echoPin = 10; // Echo pin long duration; float distance; void setup() { pinMode(trigPin, OUTPUT); pinMode(echoPin, INPUT); Serial.begin(9600); Serial.println("HC-SR04 Distance Sensor Ready"); } void loop() { // Step 1: Send 10ยตs trigger pulse digitalWrite(trigPin, LOW); delayMicroseconds(2); digitalWrite(trigPin, HIGH); delayMicroseconds(10); digitalWrite(trigPin, LOW); // Step 2: Measure echo pulse duration duration = pulseIn(echoPin, HIGH); // Step 3: Calculate distance distance = (duration * 0.034) / 2; // Step 4: Display result Serial.print("Distance: "); Serial.print(distance); Serial.println(" cm"); delay(500); }
Parking Sensor with Buzzer
Arduino // Parking sensor: buzzer beeps faster as object gets closer const int trigPin = 9; const int echoPin = 10; const int buzzerPin = 8; long duration; float distance; void setup() { pinMode(trigPin, OUTPUT); pinMode(echoPin, INPUT); pinMode(buzzerPin, OUTPUT); Serial.begin(9600); } void loop() { digitalWrite(trigPin, LOW); delayMicroseconds(2); digitalWrite(trigPin, HIGH); delayMicroseconds(10); digitalWrite(trigPin, LOW); duration = pulseIn(echoPin, HIGH); distance = (duration * 0.034) / 2; if (distance < 10) { tone(buzzerPin, 1000); // Continuous beep โ very close! } else if (distance < 30) { tone(buzzerPin, 1000, 100); // Short beep delay(distance * 10); // Beep faster when closer } else { noTone(buzzerPin); // No beep โ safe distance } delay(100); }
2.3 IR Sensor โ Object Detection
An IR sensor module has an IR LED (emitter) and a photodiode (receiver). When an object is close, IR light reflects back and the output goes LOW. It gives a digital output โ HIGH (no object) or LOW (object detected).
Arduino // Program: Object detection using IR Sensor int irPin = 7; int ledPin = 13; void setup() { pinMode(irPin, INPUT); pinMode(ledPin, OUTPUT); Serial.begin(9600); } void loop() { int irValue = digitalRead(irPin); if (irValue == LOW) { // Object detected digitalWrite(ledPin, HIGH); Serial.println("Object Detected!"); } else { digitalWrite(ledPin, LOW); Serial.println("No Object"); } delay(200); }
2.4 Worked Examples
Example 1: LDR with LED brightness (PWM)
Arduino int ldrPin = A0; int ledPin = 9; // PWM pin void setup() { pinMode(ledPin, OUTPUT); } void loop() { int val = analogRead(ldrPin); int brightness = map(val, 0, 1023, 255, 0); // Dark=bright LED analogWrite(ledPin, brightness); delay(100); }
Example 2: Ultrasonic + LCD display
Arduino #include <LiquidCrystal.h> LiquidCrystal lcd(12, 11, 5, 4, 3, 2); const int trig = 9, echo = 10; void setup() { lcd.begin(16,2); pinMode(trig,OUTPUT); pinMode(echo,INPUT); } void loop() { digitalWrite(trig,LOW); delayMicroseconds(2); digitalWrite(trig,HIGH); delayMicroseconds(10); digitalWrite(trig,LOW); float d = (pulseIn(echo,HIGH) * 0.034) / 2; lcd.clear(); lcd.print("Distance:"); lcd.setCursor(0,1); lcd.print(d); lcd.print(" cm"); delay(300); }
Example 3: IR counter (count objects passing)
Arduino int irPin = 7; int count = 0; bool lastState = HIGH; void setup() { pinMode(irPin,INPUT); Serial.begin(9600); } void loop() { bool curr = digitalRead(irPin); if (lastState == HIGH && curr == LOW) { count++; Serial.print("Count: "); Serial.println(count); } lastState = curr; delay(50); }
Example 4: Multi-zone parking (3 ultrasonic sensors)
Arduino int trig[] = {2, 4, 6}; int echo[] = {3, 5, 7}; void setup() { Serial.begin(9600); for(int i=0;i<3;i++) { pinMode(trig[i],OUTPUT); pinMode(echo[i],INPUT); } } float getDistance(int t, int e) { digitalWrite(t,LOW); delayMicroseconds(2); digitalWrite(t,HIGH); delayMicroseconds(10); digitalWrite(t,LOW); return (pulseIn(e,HIGH) * 0.034) / 2; } void loop() { for(int i=0;i<3;i++) { float d = getDistance(trig[i],echo[i]); Serial.print("Zone "); Serial.print(i+1); Serial.print(": "); Serial.print(d); Serial.println(d<20 ? " OCCUPIED" : " EMPTY"); } Serial.println("---"); delay(1000); }
Example 5: LDR night lamp with Serial plotter
Arduino void setup() { Serial.begin(9600); } void loop() { Serial.println(analogRead(A0)); // Open Serial Plotter to see graph delay(100); }
Example 6: Ultrasonic + RGB LED (distance โ color)
Arduino const int trig=9, echo=10, redPin=3, greenPin=5, bluePin=6; void setup() { pinMode(trig,OUTPUT); pinMode(echo,INPUT); pinMode(redPin,OUTPUT); pinMode(greenPin,OUTPUT); pinMode(bluePin,OUTPUT); } void loop() { digitalWrite(trig,LOW); delayMicroseconds(2); digitalWrite(trig,HIGH); delayMicroseconds(10); digitalWrite(trig,LOW); float d = (pulseIn(echo,HIGH)*0.034)/2; if(d<10){analogWrite(redPin,255);analogWrite(greenPin,0);analogWrite(bluePin,0);} else if(d<30){analogWrite(redPin,255);analogWrite(greenPin,255);analogWrite(bluePin,0);} else{analogWrite(redPin,0);analogWrite(greenPin,255);analogWrite(bluePin,0);} delay(200); }
Example 7: IR-based line follower (2 sensors)
Arduino int leftIR = 6, rightIR = 7; int motorL = 9, motorR = 10; void setup() { pinMode(leftIR,INPUT); pinMode(rightIR,INPUT); pinMode(motorL,OUTPUT); pinMode(motorR,OUTPUT); } void loop() { int L = digitalRead(leftIR), R = digitalRead(rightIR); if(L==LOW && R==LOW) { analogWrite(motorL,200); analogWrite(motorR,200); } // Forward else if(L==LOW) { analogWrite(motorL,0); analogWrite(motorR,200); } // Turn left else if(R==LOW) { analogWrite(motorL,200); analogWrite(motorR,0); } // Turn right else { analogWrite(motorL,0); analogWrite(motorR,0); } // Stop }
Example 8: LDR alarm (buzzer when too dark)
Arduino void setup() { pinMode(8,OUTPUT); } void loop() { if(analogRead(A0) < 200) tone(8,1000); else noTone(8); delay(100); }
Example 9: Ultrasonic water level monitor
Arduino const int trig=9,echo=10; const float tankHeight = 30.0; // cm void setup() { pinMode(trig,OUTPUT); pinMode(echo,INPUT); Serial.begin(9600); } void loop() { digitalWrite(trig,LOW); delayMicroseconds(2); digitalWrite(trig,HIGH); delayMicroseconds(10); digitalWrite(trig,LOW); float d = (pulseIn(echo,HIGH)*0.034)/2; float level = tankHeight - d; float pct = (level/tankHeight)*100; Serial.print("Water Level: "); Serial.print(pct); Serial.println("%"); delay(1000); }
Example 10: Combined sensor dashboard (LDR+Ultrasonic+IR on Serial)
Arduino const int trig=9,echo=10,irPin=7; void setup() { pinMode(trig,OUTPUT);pinMode(echo,INPUT);pinMode(irPin,INPUT); Serial.begin(9600); Serial.println("=== IoT Sensor Dashboard ==="); } void loop() { int ldr = analogRead(A0); digitalWrite(trig,LOW);delayMicroseconds(2); digitalWrite(trig,HIGH);delayMicroseconds(10); digitalWrite(trig,LOW); float dist = (pulseIn(echo,HIGH)*0.034)/2; int ir = digitalRead(irPin); Serial.print("Light:"); Serial.print(ldr); Serial.print(" | Dist:"); Serial.print(dist); Serial.print("cm | Object:"); Serial.println(ir==LOW?"YES":"NO"); delay(500); }
2.5 MCQs โ Chapter 2 (20 Questions)
What happens to LDR resistance in darkness?
- Decreases
- Increases
- Stays same
- Becomes zero
Which Arduino function reads analog voltage?
- digitalRead()
- analogRead()
- voltageRead()
- sensorRead()
The HC-SR04 ultrasonic sensor operates at what frequency?
- 20 kHz
- 40 kHz
- 100 kHz
- 1 MHz
What is the formula for distance using HC-SR04?
- distance = time ร 340
- distance = (time ร 0.034) / 2
- distance = time / 340
- distance = time ร 0.034
What does pulseIn(echoPin, HIGH) return?
- Voltage in volts
- Time in microseconds the pin was HIGH
- Distance in cm
- Frequency in Hz
What is the range of HC-SR04 sensor?
- 0โ10 cm
- 2โ400 cm
- 1โ1000 cm
- 10โ200 cm
An IR sensor output is LOW when:
- No object is present
- An object is detected
- Power is off
- Sensor is broken
In an LDR voltage divider, the fixed resistor is typically:
- 100ฮฉ
- 1kฮฉ
- 10kฮฉ
- 1Mฮฉ
analogRead() returns a value in the range:
- 0โ255
- 0โ1023
- 0โ4095
- 0โ65535
Which trigger pulse duration is needed for HC-SR04?
- 2 ยตs
- 10 ยตs
- 100 ยตs
- 1 ms
What type of output does an IR obstacle sensor give?
- Analog
- Digital
- PWM
- Serial
map(val, 0, 1023, 0, 255) converts analog reading to:
- Voltage
- PWM duty cycle range
- Temperature
- Distance
Speed of sound used in ultrasonic calculation is approximately:
- 340 m/s
- 3400 m/s
- 34 m/s
- 34000 m/s
Which application uses LDR sensors in India?
- Automatic street lights
- Motor speed control
- Temperature measurement
- RFID reading
How many pins does the HC-SR04 module have?
- 2
- 3
- 4
- 6
For a line follower robot, which sensor is used?
- LDR
- Ultrasonic
- IR sensor
- Temperature sensor
What is the ADC resolution of Arduino Uno?
- 8-bit
- 10-bit
- 12-bit
- 16-bit
Which function generates a square wave on a pin for a buzzer?
- analogWrite()
- tone()
- buzz()
- sound()
Why do we divide the ultrasonic time by 2?
- To convert units
- Sound travels to object and back (round trip)
- Sensor has 2 pins
- Arduino clock is 2x faster
What component is paired with LDR in a voltage divider?
- Capacitor
- LED
- Fixed resistor
- Transistor