Lab 6
Lab 6
Lab-6
Task 1: Design an alarm system that triggers warning if a package gets damaged. Use
force sensor and a buzzer alarm.
Algorithm
1. Initialize Components
Code
void loop() {
int sensorValue = analogRead(forceSensorPin);
Serial.println(sensorValue);
delay(100);
}
Output
The alarm and the LED bulb are off when the force applied is below the threshold.
The alarm rings and the LED bulb glows when the force crosses the threshold limit.
Task 2: Develop a smoke detecting system for a building consisting of three floors.
Notify the real-time value of the floors to thingspeak IoT cloud platform.
Algorithm
1. Initialize Components:
If any sensor reading exceeds 85, activate the buzzer (tone(7, 1000)).
Otherwise, turn OFF the buzzer (noTone(7)).
void setup() {
delay(100);
Serial.begin(115200);
Serial.println("AT+CWJAP=\"Simulator Wifi\",\"\"\r\n");
delay(3000);
pinMode(7, OUTPUT);
pinMode(A0, INPUT);
pinMode(A1, INPUT);
pinMode(A2, INPUT);
}
void loop() {
val1 = analogRead(A0);
val2 = analogRead(A1);
val3 = analogRead(A2);
Serial.println("AT+CIPSTART=\"TCP\",\"api.thingspeak.com\",80\r\n");
delay(3000);
Serial.print("AT+CIPSEND=");
Serial.println(request.length() + 2);
delay(1000);
Serial.print(request);
delay(1000);
Serial.println("AT+CIPCLOSE=0\r\n");
delay(10000);
}
Output
Simulation