Components needed
Arduino Uno
LED (any colour)
220Ω Resistor
Breadboard
Jumper wires
Wiring
| Component | Pin / Terminal | Arduino |
|---|---|---|
| LED (+) Anode | — | Pin 13 (via 220Ω) |
| LED (−) Cathode | — | GND |
| Resistor | Between Pin 13 & LED | In series |
task1_led_control.ino
/* * Task 1 — Basic Output Control * Blinks an LED connected to Pin 13. * Components: LED, 220Ω resistor */ const int LED_PIN = 13; void setup() { pinMode(LED_PIN, OUTPUT); // Set pin as output Serial.begin(9600); Serial.println("Task 1 — LED Control started"); } void loop() { digitalWrite(LED_PIN, HIGH); // LED ON Serial.println("LED: ON"); delay(1000); // Wait 1 second digitalWrite(LED_PIN, LOW); // LED OFF Serial.println("LED: OFF"); delay(1000); // Wait 1 second }
Components needed
Arduino Uno
LED
220Ω Resistor
Breadboard
Jumper wires
Wiring — use a PWM-capable pin (~)
| Component | Terminal | Arduino |
|---|---|---|
| LED (+) Anode | — | Pin 9 ~ (via 220Ω) |
| LED (−) Cathode | — | GND |
task2_pwm_brightness.ino
/* * Task 2 — Variable Control System * Fades an LED in and out using PWM on Pin 9. * PWM range: 0 (off) → 255 (full brightness) */ const int LED_PIN = 9; // Must be a PWM pin (~) void setup() { pinMode(LED_PIN, OUTPUT); Serial.begin(9600); Serial.println("Task 2 — PWM Brightness started"); } void loop() { // Fade IN: 0 → 255 for (int brightness = 0; brightness <= 255; brightness++) { analogWrite(LED_PIN, brightness); Serial.print("Brightness: "); Serial.println(brightness); delay(8); } // Fade OUT: 255 → 0 for (int brightness = 255; brightness >= 0; brightness--) { analogWrite(LED_PIN, brightness); Serial.print("Brightness: "); Serial.println(brightness); delay(8); } delay(300); // Pause before repeating }
Components needed
Arduino Uno
Push Button
LED
220Ω Resistor
10kΩ Resistor (pull-down)
Breadboard
Wiring
| Component | Terminal | Arduino |
|---|---|---|
| Button (one leg) | — | Pin 2 |
| Button (same leg) | — | 10kΩ → GND (pull-down) |
| Button (other leg) | — | 5V |
| LED (+) Anode | — | Pin 13 (via 220Ω) |
| LED (−) Cathode | — | GND |
task3_button_led.ino
/* * Task 3 — User Interaction System * Push button toggles LED on/off. * Uses debounce logic for clean input reading. */ const int BTN_PIN = 2; const int LED_PIN = 13; bool ledState = false; bool lastBtnState = false; unsigned long lastDebounce = 0; const int DEBOUNCE_MS = 50; void setup() { pinMode(BTN_PIN, INPUT); // External pull-down resistor pinMode(LED_PIN, OUTPUT); Serial.begin(9600); Serial.println("Task 3 — Button Toggle ready"); } void loop() { bool btnReading = digitalRead(BTN_PIN); // Detect rising edge with debounce if (btnReading == true && lastBtnState == false) { if (millis() - lastDebounce > DEBOUNCE_MS) { ledState = !ledState; // Toggle state digitalWrite(LED_PIN, ledState); Serial.print("Button pressed — LED: "); Serial.println(ledState ? "ON" : "OFF"); lastDebounce = millis(); } } lastBtnState = btnReading; }
Components needed
Arduino Uno
Passive Buzzer
Push Button
10kΩ Resistor
Breadboard
Wiring
| Component | Terminal | Arduino |
|---|---|---|
| Buzzer (+) | Positive | Pin 8 |
| Buzzer (−) | Negative | GND |
| Button (one leg) | — | Pin 2 + 10kΩ → GND |
| Button (other leg) | — | 5V |
task4_buzzer_alert.ino
/* * Task 4 — Alert / Notification System * Button triggers a buzzer alarm with escalating tones. * Uses tone() for passive buzzer frequency control. */ const int BUZZER_PIN = 8; const int BTN_PIN = 2; void setup() { pinMode(BUZZER_PIN, OUTPUT); pinMode(BTN_PIN, INPUT); Serial.begin(9600); Serial.println("Task 4 — Alert System ready"); } void playAlert(int level) { switch (level) { case 1: // Single short beep tone(BUZZER_PIN, 1000, 200); delay(300); break; case 2: // Double beep tone(BUZZER_PIN, 1500, 150); delay(200); tone(BUZZER_PIN, 1500, 150); delay(200); break; case 3: // Alarm siren for (int freq = 800; freq <= 2400; freq += 100) { tone(BUZZER_PIN, freq); delay(30); } noTone(BUZZER_PIN); break; } } int alertLevel = 1; void loop() { if (digitalRead(BTN_PIN) == HIGH) { Serial.print("Alert level: "); Serial.println(alertLevel); playAlert(alertLevel); alertLevel++; if (alertLevel > 3) alertLevel = 1; // Cycle 1 → 2 → 3 → 1 delay(400); } }
Components needed
Arduino Uno
DHT11 Sensor
16×2 LCD (I2C)
10kΩ Resistor
Jumper wires
Wiring
| Component | Terminal | Arduino |
|---|---|---|
| DHT11 | VCC | 5V |
| DHT11 | GND | GND |
| DHT11 | DATA | Pin 7 (+ 10kΩ to 5V) |
| LCD I2C | VCC | 5V |
| LCD I2C | GND | GND |
| LCD I2C | SDA | A4 |
| LCD I2C | SCL | A5 |
Libraries required
DHT sensor library — Adafruit
LiquidCrystal_I2C
Wire.h (built-in)
task5_dht11_lcd.ino
/* * Task 5 — Display / Information System * Reads DHT11 sensor and shows temp + humidity on LCD. * Libraries: Adafruit DHT, LiquidCrystal_I2C */ #include <DHT.h> #include <Wire.h> #include <LiquidCrystal_I2C.h> #define DHT_PIN 7 #define DHT_TYPE DHT11 DHT dht(DHT_PIN, DHT_TYPE); LiquidCrystal_I2C lcd(0x27, 16, 2); // Address 0x27, 16 cols, 2 rows void setup() { Serial.begin(9600); dht.begin(); lcd.init(); lcd.backlight(); lcd.setCursor(0, 0); lcd.print(" Sensor Ready "); lcd.setCursor(0, 1); lcd.print(" Initializing.. "); delay(2000); lcd.clear(); Serial.println("Task 5 — DHT11 + LCD ready"); } void loop() { float humidity = dht.readHumidity(); float temperature = dht.readTemperature(); // Celsius if (isnan(humidity) || isnan(temperature)) { lcd.clear(); lcd.print("Sensor error!"); Serial.println("ERROR: DHT11 read failed"); delay(2000); return; } // LCD Row 1: Temperature lcd.setCursor(0, 0); lcd.print("Temp: "); lcd.print(temperature, 1); lcd.print(" C "); // LCD Row 2: Humidity lcd.setCursor(0, 1); lcd.print("Hum: "); lcd.print(humidity, 1); lcd.print(" % "); Serial.print("Temp: "); Serial.print(temperature); Serial.print("°C "); Serial.print("Humidity: "); Serial.print(humidity); Serial.println("%"); delay(2000); // Update every 2 seconds }