1. Design and implement a system using Arduino Board where pressing a push buttontoggles an LED ON and OFF.
int led = 13;
int button = 2;
int state = 0;
void setup() {
pinMode(led, OUTPUT);
pinMode(button, INPUT_PULLUP);
}
void loop() {
if (digitalRead(button) == LOW) {
state = !state;
digitalWrite(led, state);
delay(300); }
}
2.
3. Develop a motion detection system using a PIR sensor interfaced with Arduino board.
int pir = 2,
led = 13,
buzzer = 4;
void setup() {
pinMode(pir, INPUT);
pinMode(led, OUTPUT);
pinMode(buzzer, OUTPUT);
} void loop() {
if (digitalRead(pir)) {
digitalWrite(led, HIGH);
digitalWrite(buzzer, HIGH);
} else {
digitalWrite(led, LOW);
digitalWrite(buzzer, LOW);
}
}
5. Build an IoT system using NodeMCU and DHT11 sensor to measure temperature andhumidity and upload to ThingSpeak.
#include <ESP8266WiFi.h>
#include "DHT.h"
#include <ThingSpeak.h>
const char* ssid = "YourWiFi";
const char* pass = "YourPassword";
WiFiClient client;
unsigned long ch = YOUR_CHANNEL_ID;
const char* key = "YOUR_API_KEY";
DHT dht(D2, DHT11);
void setup() {
WiFi.begin(ssid, pass);
ThingSpeak.begin(client);
dht.begin();
} void loop() {
float t = dht.readTemperature();
float h = dht.readHumidity();
ThingSpeak.setField(1, t);
ThingSpeak.setField(2, h);
ThingSpeak.writeFields(ch, key);
delay(20000); }
6. Build an IoT system using NodeMCU and DHT11 sensor to measure temperature and humidity with buzzer alert.
#include "DHT.h"
#define DHTPIN D2
#define DHTTYPE DHT11
#define BUZZER D3
DHT dht(DHTPIN, DHTTYPE); void setup() { pinMode(BUZZER, OUTPUT); dht.begin(); } void loop() { float t = dht.readTemperature(); if (t > 30) digitalWrite(BUZZER, HIGH); else digitalWrite(BUZZER, LOW); delay(2000); }
7. Create a distance monitoring system using Raspberry Pi and ultrasonic sensor.
import RPi.GPIO as GPIO, time TRIG=23; ECHO=24
GPIO.setmode(GPIO.BCM)
GPIO.setup(TRIG,GPIO.OUT) GPIO.setup(ECHO,GPIO.IN) while True: GPIO.output(TRIG, True) time.sleep(0.00001) GPIO.output(TRIG, False) while GPIO.input(ECHO)==0: start=time.time() while GPIO.input(ECHO)==1: end=time.time() dist=(end-start)*17150 print("Distance:", round(dist,2),"cm") time.sleep(1)
8. Simulate a distance monitoring system in Wokwi using Raspberry Pi and ultrasonicsensor.
#define TRIG 2
#define ECHO 3 #define LED 4
long dur; int dist; void setup() { pinMode(TRIG, OUTPUT); pinMode(ECHO, INPUT); pinMode(LED, OUTPUT); Serial.begin(9600); } void loop() {
digitalWrite(TRIG, LOW); delayMicroseconds(2); digitalWrite(TRIG, HIGH); delayMicroseconds(10); digitalWrite(TRIG, LOW); dur = pulseIn(ECHO, HIGH); dist = dur * 0.034 / 2; Serial.println(dist); if (dist > 20) digitalWrite(LED, HIGH); else digitalWrite(LED, LOW); delay(500); }
9. Simulate a distance monitoring system in Wokwi using Raspberry Pi and ultrasonicsensor.
Use the same code as Q8.
10. Design and implement a stepper motor control system using ESP8266 (NodeMCU).
#include <Stepper.h>
#define STEPS 200 Stepper stepper(STEPS, D1, D2, D3, D4); void setup() {} void loop() { stepper.setSpeed(50); stepper.step(200); delay(1000); stepper.step(-200); delay(1000); }
11. Simulate a stepper motor control system in Wokwi using NodeMCU.
Same as Q10.
12. Develop a color detection system using TCS3200 and ESP8266 (NodeMCU) that sendscolor data to Blynk.
#include <BlynkSimpleEsp8266.h> char auth[] = "YourAuth"; char ssid[] = "WiFi"; char pass[] = "Pass"; void setup() { Blynk.begin(auth, ssid, pass);
Serial.begin(9600); } void loop() {
int color = analogRead(A0); Blynk.virtualWrite(V1, color); delay(1000); }
13. Develop a color detection system using TCS3200 and NodeMCU.
int color; void setup() { pinMode(A0, INPUT); Serial.begin(9600); } void loop() { color = analogRead(A0); Serial.println(color); delay(1000); }
14. Implement a gas leakage monitoring system using MQ2 sensor and NodeMCU.
#define MQ2 A0 #define BUZZER D1 void setup() { pinMode(MQ2, INPUT); pinMode(BUZZER, OUTPUT); } void loop() {
int gas = analogRead(MQ2); if (gas > 300) digitalWrite(BUZZER, HIGH); else digitalWrite(BUZZER, LOW); delay(1000);
}
15. Implement a gas leakage monitoring system using MQ2 sensor.
Same as Q14 without NodeMCU WiFi functions.
16. Implement a simple LED control system using NodeMCU and Blynk app.
#include <BlynkSimpleEsp8266.h> char auth[] = "YourAuth"; char ssid[] = "WiFi"; char pass[] = "Pass"; int led = D2; void setup() { pinMode(led, OUTPUT); Blynk.begin(auth, ssid, pass);
} BLYNK_WRITE(V1) { int pinValue = param.asInt(); digitalWrite(led, pinValue); } void loop() { Blynk.run();
}