C9: Arduino / RPi Pico Advanced + Sensor Interfacing

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)

  1. Set Up Your Microcontroller

    • Connect the Arduino/Pico to your computer using a USB cable.

    • Open the appropriate coding software (Arduino IDE or Thonny).

  2. 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.

  3. 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.

  1. Upload and Run the Code

    • Click the Upload button in Arduino IDE or run in Thonny.

  2. Open the Serial Monitor / Python Shell

    • For Arduino: Tools → Serial Monitor.

    • For Pico: Use print() in Python to display in Thonny Shell.

  3. Observe the Data

    • For LM35: Temperature changes when you touch or heat it.

    • For LDR: Values change when you shine light or cover it.

  4. Record Observations

    • Note how fast the readings change.
    • Compare values under different conditions.
Fill in the form for S’O’A Fablab Orientation 2021.