Practical 1a
Practical 1a
Objective:
Students will design and implement a simple embedded system that measures temperature and
provides feedback using an LED, demonstrating real-time functionality and application-specific
design.
Materials:
Arduino board (or any microcontroller)
Temperature sensor (e.g., LM35 or DHT11)
LED
Resistors (220 ohms for the LED)
Breadboard and jumper wires
Laptop with Arduino IDE installed
USB cable for programming the Arduino
Step-by-Step Instructions:
1. Setup (10 minutes):
o Connect the temperature sensor to the Arduino:
VCC (power) to the 5V pin on the Arduino.
GND (ground) to the GND pin.
Data pin to any analog input pin (e.g., A0).
o Connect the LED to the breadboard:
Connect one leg of the LED (longer leg) to a digital pin (e.g., D3) through
a 220-ohm resistor.
Connect the shorter leg to GND.
2. Programming the Microcontroller (20 minutes):
o Open the Arduino IDE and write the following code:
int sensorPin = A0; // Analog pin connected to the temperature sensor
int ledPin = 3; // Digital pin connected to the LED
int threshold = 30; // Temperature threshold in Celsius
void setup() {
pinMode(ledPin, OUTPUT); // Set the LED pin as output
Serial.begin(9600); // Start the serial communication
}
void loop() {
int sensorValue = analogRead(sensorPin); // Read sensor data
float voltage = sensorValue * (5.0 / 1023.0); // Convert to voltage
float temperature = voltage * 100.0; // Convert to Celsius (for LM35)
Serial.print("Temperature: ");
Serial.print(temperature);
Serial.println(" °C");
Expected Outcome:
Students will have hands-on experience building and programming a basic embedded system,
reinforcing theoretical knowledge and understanding of embedded systems' practical
applications.