Fab Academy 2024

@ Fab Lab Rwanda, Kigali

Input Devices:

Digital Signals

This work details our group's assignment to probe an input device's signals.

For digital signals, We worked with a push button to observe its digital signal using an oscilloscope.

What we did;

Our approach to probing the input device signals involved the following steps:

  1. Setup the Circuit:
    • The board we designed in previous assigment was used as a reference input device as it is built with a push button.
    • One terminal of the push button was connected to a digital input pin and the other terminal to ground.
    • A pull-down resistor ensured a clear HIGH or LOW state when the button was pressed or released.
  2. Connect the Oscilloscope:
    • The oscilloscope probe was connected to the junction between the push button and the digital input pin.
    • The ground clip of the oscilloscope was connected to the ground of the circuit.
  3. Code used

    // Button connected to digital pin D1 const int buttonPin = D1; void setup() { // Initialize serial communication at 115200 baud Serial.begin(115200); // Initialize the button pin as an input with an internal pull-down resistor pinMode(buttonPin, INPUT_PULLDOWN); } void loop() { // Read the digital value from the button int buttonValue = digitalRead(buttonPin); // Print the button state to the serial monitor Serial.print("Button State: "); if (buttonValue == HIGH) { Serial.println("HIGH"); } else { Serial.println("LOW"); } // Wait for a short period before reading the value again delay(1000); }

    Click Here to Download the Code

  4. Press the Button:
    • The push button was pressed and released multiple times.
    • The corresponding signals were observed and recorded using the oscilloscope.

Observations

When the push button was pressed, the oscilloscope displayed a clear transition from LOW (0V) to HIGH (typically 5V for a standard digital signal). Upon releasing the button, the signal transitioned back to LOW. The debounce effect, which is noise caused by the mechanical contacts of the button, was observed as small fluctuations before the signal stabilized.

Video of the oscilloscope

Probing the push button with an oscilloscope provided a clear visual representation of the digital signal transitions. This exercise helped in understanding the behavior of the push button as an input device and the importance of debouncing in digital circuits.

Analog Levels

This part demonstrates input device's signals as analog levels using a capacitive moisture sensor. The objective was to read and monitor the sensor's values in different environments: outside and in wet soil.

Our approach to probing the capacitive moisture sensor signals involved the following steps:

  1. Setup the Circuit:
    • The capacitive moisture sensor was connected to an analog input pin of the the board.
    • The sensor's VCC pin was connected to the 5V pin, the GND pin to ground, and the signal pin to an analog input (A0) on the microcontroller.
  2. Read and Monitor Values:
    • The sensor was placed in two different environments: outside and in wet soil.
    • The analog values from the sensor were read and displayed on the serial monitor.
    • Observations were recorded for the sensor's readings in each environment.

Observations

Outside (Air): he sensor reading was low, indicating minimal or no moisture.

Wet Soil: The sensor reading increased significantly, indicating higher moisture levels due to the presence of water in the soil.

Code used

// Include the necessary libraries #include // Define the pin where the moisture sensor is connected const int sensorPin = A2; // Variables to store the sensor value and the mapped value int sensorValue = 0; int mappedValue = 0; void setup() { // Initialize serial communication at 115200 baud Serial.begin(115200); // Initialize the sensor pin as an input pinMode(sensorPin, INPUT); } void loop() { // Read the analog value from the moisture sensor sensorValue = analogRead(sensorPin); // Map the sensor value from 0-4095 to 100-0 // Assuming the ESP32 ADC resolution is 12-bit (0-4095) mappedValue = map(sensorValue, 0, 4095, 100, 0); // Print the sensor value and the mapped value to the serial monitor Serial.print("Moisture Sensor Value: "); Serial.print(sensorValue); Serial.print(" | Mapped Value: "); Serial.println(mappedValue); // Wait for 1 second before reading the value again delay(1000); }

Click Here to Download the Cpde

In air values of sensor readings

In wet environment values increase

Probing the capacitive moisture sensor provided valuable insights into its behavior in different environments. This exercise helped in understanding the sensor's response to varying moisture levels, which is crucial for applications in agriculture and soil monitoring.

Instructor

Contacts

  • Map
  • +250 781 187 555