Input Devices

This Week I worked on Input Devices

Assignment Brief:

  1. As a group probe an input device's analog levels and analyze its digital signals.
  2. Measure a parameter using a sensor. Integrate the sensor with a custom-designed microcontroller board and read its data.

Input Devices: Previously

Input devices are hardware components that allow users to enter data, commands, or signals into a computer or other electronic systems. They convert physical actions or external data into digital signals that the system can process.

Personally, I had used an ultra sonic sensor in on eof the mini projects I did a year age, which was the first time I understood basics of Input and output devices. So, the first input device I used was an ultra sonic sensor. I also used a servo motor as an output. The project was a simple game, inspired by the mobile application game of Talking Tom, I built a frowning Cat, who uses a knife whenever a user comes near.

gimp1
gimp1

Input Devices: Week 09

Later, to understand the existing Input devices, I referred to the internet and chat gpt to leanr about the existing Input devices and their range of study. To learn more about sensors you can visit Autodesk Instructables to find DIY projects related to these sensors.

gimp1
gimp1

In this week, as I learnt about different sensors, I analysed the sensor that I could incorporate in my Final Project. After talking to my mentors Pranav Gawde and Jesal Mehta, I finalized the sensors that could help my final project idea. As per this and as an explorative lense I chose the sensors I would use for this week. That is:

  1. Touch sensor
  2. Accelorometer MP6040 6-axis (This I tried for explorative purpose.)

gimp1
gimp1
You can buy the Accelerometer and Ultrasonic sensor from Robu.in, Bolow is the link attatched to buy, MPU-6050 3-Axis Accelerometer and Gyro Sensor, the price for which is Rs. 189 as per Indian currency and an Touch sensor, the price for which is Rs. 24 as per Indian currency. As the products arrived, I understood the pinouts of both the sensors.

gimp1
gimp1

Touch Sensor

For better understanding of how I went through the project, lets go step by step. First Lets understand the Touch sensor. A touch sensor detects physical contact (like a finger touch) and converts it into an electrical signal. It is commonly used in touchscreens, buttons, and interactive devices.


Touch Sensor Type Working Principle Applications Advantages Limitations
Capacitive Measures changes in capacitance when a conductive object (finger) disrupts the electric field. Smartphones, touchpads, control panels, tablets. High sensitivity, multi-touch support, durable, scratch-resistant. Doesn't work with non-conductive objects (gloves, stylus), affected by water/humidity, higher cost.
Resistive Two conductive layers separated by a gap touch when pressed, completing a circuit. ATMs, industrial touchscreens, older touch devices. Works with any object (stylus, gloves), lower cost, durable in harsh conditions. Less sensitive, no multi-touch support, prone to wear and tear.
Infrared Uses IR LEDs and photodetectors; touch blocks the infrared beam. Interactive kiosks, public touch displays, medical devices. Works with any material, long lifespan, high durability. Can be affected by dirt, dust, and strong ambient light.
Piezoelectric Generates a small electric charge when pressure is applied. Industrial applications, harsh environments, touch-sensitive musical instruments. High durability, works in extreme conditions, no need for conductive materials. Expensive, requires strong force to activate.
Optical Uses cameras or light sensors to detect touch disruptions. Large interactive displays, multi-touch tables, high-end kiosks. High accuracy, supports multi-touch, durable. Expensive, bulky, requires calibration.


I used the a capacitive touch sensorwhich detects touch by measuring changes in electrical capacitance. It consists of a conductive surface and an electric field. When a conductive object (like a human finger) comes close, it disrupts the field, changing the capacitance. Surface Capacitive - Uses a thin conductive layer where a small current flows upon touch.

Design and Fabrication: refer to Week 06: Electronics Design.
Pcb production: refer to Week 08: PCB Production

gimp1
gimp1
gimp1
gimp1

Relevance to Final Project

Coding part: Made flow chart and used Chatgpt Ai prompt: Give a code for rp2040 connection on aurdino ide for the above connection. I was mesmerized by the code output that i received from chatgpt. As I read the code. the code read every bit well.

gimp1
Once, I soldered the componenets and used the chatgpt generated code to power my input device code. At first the code didn't work.

Didn't read USB COM

gimp1

Selected the seed xaio rp2040 board and selected port.

gimp1

Learnings: The code was pushed succesfully but didnt work perfectly. I realised the pin numbers needed to be changes. The biggest issue with the code was the aurdino Uno Library. The code that ai generated didnt include the libraried to run the code.

Touch Sensor

gimp1

To understand the structure of complex code, I decided to first explore its smaller components. I started with the touch sensor and used the Serial Monitor to observe its raw analog output. By reading values from pin D0 on the Seeed XIAO RP2040, I could see how the sensor responded to touch in real time.

Later, I chose to go step by step to give the code. Fist I generated the code for the touch sensor.I used code for Xaio and mentioned pin numbers and other specifications as well. Ai prompt: Generate a code to monitor input signal for a touch sensor connected to pin D0 on Xaio RP2040. Note as per New updates on Arduino IDE, the pin cofiguration for pin 0 is D0.

Uploaded the code to Arduino IDE, buy selecting the board as Xaio RP204O. gimp1
Run the code to the Xaio RP2040 gimp1
Read the readings on the code, by interactively touching the sensor. gimp1
Cntrl+ shift+ M to open the Serial Monitor and check its output readings.
The values bounce between ~6 and 1023, suggesting: The sensor is not touched (values near 6). The sensor is fully triggered/touched (1023 = max analogRead). gimp1

Learnings: This allowed me to observe real-time sensor data and understand how it behaves under different conditions—such as when it is touched versus untouched. I monitored the value fluctuations, which helped me identify key thresholds and assess the consistency of the sensor’s output.

Accelerometer MP6040 6-axis

Got a Accelerometer MP6040 6-axis gimp1
Soldered it with header pins. gimp1

Wiring (I2C Protocol)

VCC → 3.3V or 5V
SDA → A4 (on Uno/Nano)
SCL → A5 (on Uno/Nano)
Common GND

Code set-up

Go to Arduino IDE > Tools > Manage Libraries> "MPU6050"> Install gimp1
Once Installed select the board as Arduino UNO. gimp1
Connect the Arduino UNO to the USB and upload the code below. gimp1
Uploaded Code gimp1

The serial monitor displays live sensor data being streamed from the MPU-6050 module interfaced with an Arduino board. This real-time feedback helps validate sensor functionality and observe changes in orientation, motion, and temperature.



Quentorres Board

In the Similar manner I tried using the quentorres board to monitor the Accelorometer. Referring to the belove connections. gimp1

Wiring: I was unaware that Xaio works on 3.3 V for input devices, I connected the Arduino VCC to Xaio 5V. gimp1
Changed the board to Xaio RP2040 gimp1
Uploaded Code gimp1
    #include 
        #include 
        
        MPU6050 mpu;
        
        void setup() {
          Serial.begin(115200);  // Start serial communication
          Wire.begin();          // Start I2C communication
        
          Serial.println("Initializing MPU6050...");
          mpu.initialize();
        
          // Check connection
          if (mpu.testConnection()) {
            Serial.println("MPU6050 connection successful!");
          } else {
            Serial.println("MPU6050 connection failed!");
            while (1);  // Stop execution
          }
        }
        
        void loop() {
          int16_t ax, ay, az;
          int16_t gx, gy, gz;
          int16_t temp;
        
          // Read data from MPU6050
          mpu.getAcceleration(&ax, &ay, &az);
          mpu.getRotation(&gx, &gy, &gz);
          temp = mpu.getTemperature();
        
          // Print values to Serial Monitor
          Serial.print("Acceleration: X=");
          Serial.print(ax);
          Serial.print(" Y=");
          Serial.print(ay);
          Serial.print(" Z=");
          Serial.print(az);
        
          Serial.print(" | Temperature: ");
          Serial.print(temp / 340.00 + 36.53);  // Convert raw temp to °C
        
          Serial.print(" | Gyroscope: X=");
          Serial.print(gx);
          Serial.print(" Y=");
          Serial.print(gy);
          Serial.print(" Z=");
          Serial.println(gz);
        
          delay(500);  // Wait half a second
        }
        
    Reminder, Include libraries Wireh and MPU6050 in the above code.

Code Failed Uploading, Learnings: I burnt the Xaio on the Quentorres board, I also tried the same code on my own PCB board assuming that the Quentorres board might be having errors and burnt it as well. Next, a heavy learning lesson came by my way. While using the RP2040 Remember: gimp1

Step Response

My professor's Pranav Gawde and Jesal Mehta guided and taught me the basics of step response. gimp1

I referred to Step response Link 1 and Andrian Toress Step response links to understand the how step response works.

Sensing with Step Response (transmit-receive, or tx-rx)

  • The transmit (TX) pin is alternately made high (5V or 3.3V) and low (0V). Note that the figures show values for 5V boards. For 3V boards (like ATSAM-based Adafruit boards), the highest voltage is 3.3V.
  • This process charges and discharges the TX electrode.
  • On the RX electrode, a small 'blip' (up or down) occurs as the TX pin toggles.
  • These blips are measured by the Arduino analog input (ADC), and the "low" value is subtracted from the "high" value.
  • This result varies depending on how closely the two plates are coupled by the electric field. It increases as the distance decreases and also changes with the amount of overlap and the material between the plates.
  • gimp1
    gimp1
    gimp1
    gimp1
    gimp1
    gimp1

    When the copper plates are away.

    gimp1

    When the copper plates touch together.

    gimp1

    Learnings:

    1. Understanding Pressure Sensors: A pressure sensor works by converting mechanical pressure (force) into an electrical signal. When force is applied, the internal structure (usually piezoresistive, capacitive, or resistive) changes its properties like resistance or capacitance. This change can be measured and mapped to a value of pressure or force using simple circuitry or microcontroller input.

    2. Electric Field Generation Concept: Applying pressure can alter the electric field between materials, especially in capacitive sensors. In capacitive sensing: Two conductive plates with a dielectric in between form a capacitor. When pressure changes the distance between plates or compresses the dielectric, the capacitance changes. This variation can be detected as a signal using an analog pin on a microcontroller like Arduino.

    3. Compact Design Thinking: To make pressure sensors work in compact designs, I understood: Use thin, flexible materials (like Velostat, piezo films, or conductive foam). Integrate directly into wearables or layered components like insoles, bands, or straps. Minimize circuit complexity by using modular microcontrollers and I2C or analog signals to read values.

    Project files

    Step response graph code
    Step response serial code
    Arduino to Accelerometer code
    Xaio to Accelerometer code

    Image Links

    Image Link.
    Image Link.
    Image Link.
    Image Link.