Input Devices


Assignment
  • Group Assignment:
    • Probe an input device(s)'s analog and digital signals.
    • Document your work on the group work page and reflect on your individual page what you learned.
  • Individual Assignment:
    • Measure something: add a sensor to a microcontroller board that you have designed and read it.
Evaluation Standards
  • Linked to the group assignment page.
  • Documented what you learned from interfacing an input device(s) to your microcontroller and how the physical property relates to the measured results.
  • Documented your design and fabrication process or linked to the board you made in a previous assignment.
  • Explained the programming process/es you used.
  • Explained any problems you encountered and how you fixed them.
  • Included original design files and source code.
  • Included a 'hero shot' of your board.
Output Preview

Group Assignment

We start by probing an IR sensor and we observe it's signal using oscilloscope.
we supplied the IR sensor with 5V and probed the output pin and we observe the oscilloscope
The signal changes as we interact with the IR sensor high or low


Check our Group assignment page to see more of our assignment.




Measuring Something
Step Response

The Step Response is a sensor that is made with two sheets of copper. It can be used to calculate the value of force, weight, resistance...etc.
I have followed Robert Hart's tutorial as well as Adrian's Example.

  • For this week I used my Xiao board that I designed and fabricated
  • I designed and fabricated a step response adaptor for my Xioa board
Step Response Code
                                    
long result;
int analog_pin = 27;
int tx_pin = 26;
void setup() {
pinMode(tx_pin,OUTPUT);
Serial.begin(115200);
}


long tx_rx(){         //Function to execute rx_tx algorithm and return a value
                      //that depends on coupling of two electrodes.
                      //Value returned is a long integer.
  int read_high;
  int read_low;
  int diff;
  long int sum;
  int N_samples = 100;    //Number of samples to take.  Larger number slows it down, but reduces scatter.

  sum = 0;

  for (int i = 0; i < N_samples; i++){
   digitalWrite(tx_pin,HIGH);              //Step the voltage high on conductor 1.
   read_high = analogRead(analog_pin);        //Measure response of conductor 2.
   delayMicroseconds(100);            //Delay to reach steady state.
   digitalWrite(tx_pin,LOW);               //Step the voltage to zero on conductor 1.
   read_low = analogRead(analog_pin);         //Measure response of conductor 2.
   diff = read_high - read_low;       //desired answer is the difference between high and low.
 sum += diff;                       //Sums up N_samples of these measurements.
 }
  return sum;
}                         //End of tx_rx function.


void loop() {

result = tx_rx();
Serial.println(result);
delay(100);
}
                                    
                                

Capacitive Touch

The Capacitive Touch is a sensor that is made with one sheets of copper. That can be used to detect the touch by sensing the change in voltage as the plate charges up. The closer the grounded object is to the plate, the larger the capacitance, and the longer it takes to charge.
I made a tiny Capacitive Touch to use with my Xiao board
I have followed Robert Hart's tutorial.

Capacitive Touch Code
                                
#include <FastCapacitiveSensor.h>
#define send 27
#define receive 26

FastCapacitiveSensor sensor1;

void setup() {
  pinMode(send, OUTPUT);
  pinMode(receive, INPUT);
  Serial.begin(115200);
  sensor1.begin(send, receive, 1.85, 500, 500, 0.3);
}

void loop() {
  Serial.println(sensor1.touch());
}                                        
                                
                            

Challanges
The Capacitive Sensing Library that Robert Hart used in his example didn't work with the Xaio RP2040 so after a little bit of resurch. I found Fast Capacitive Sensor Library which is compatible with the RP2040 and I use it to make my Capacitive Touch example.