Aim:
To collect and display live sensor readings from a temperature or light sensor.
Requirements:
- Arduino Uno or Raspberry Pi Pico
- LM35 temperature sensor or LDR (light-dependent resistor)
- Breadboard and jumper wires
- USB cable
- Computer with Arduino IDE (for Arduino) or Thonny IDE (for Pico)
Procedure (Step-by-Step)
- Set Up Your Microcontroller
- Connect the Arduino/Pico to your computer using a USB cable.
- Open the appropriate coding software (Arduino IDE or Thonny).
- Connect the Sensor
- LM35:
- Vcc → 5V
- GND → Ground
- Output → Analog pin (e.g., A0)
- LDR:
- One leg to 5V
- Other leg to A0 with a resistor to GND.
- LM35:
- Write the Code
Arduino Example:
cpp
CopyEdit
int sensorValue = analogRead(A0);
Serial.println(sensorValue);
delay(1000); // wait 1 second
- This reads the sensor value every second and prints it.
- Upload and Run the Code
- Click the Upload button in Arduino IDE or run in Thonny.
- Open the Serial Monitor / Python Shell
- For Arduino: Tools → Serial Monitor.
- For Pico: Use print() in Python to display in Thonny Shell.
- Observe the Data
- For LM35: Temperature changes when you touch or heat it.
- For LDR: Values change when you shine light or cover it.
- Record Observations
- Note how fast the readings change.
- Compare values under different conditions.