12. Input devices

On this week we worked on THE CREATION OF THE CNC (difficult week)

The group assignment

Here is the group assignment where you can find about an input device(s)'s analog levels and digital signals

Input device: Ultrasonic sensor

First I decided go for a comun sensor, so I started with the Ultrasonic Sensor. Ultrasonic sensors are electronic devices that calculate the target’s distance by emission of ultrasonic sound waves and convert those waves into electrical signals. The speed of emitted ultrasonic waves traveling speed is faster than the audible sound

On this sensor, there are mainly two essential elements which are the transmitter and receiver. Using the piezoelectric crystals, the transmitter generates sound, and from there it travels to the target and gets back to the receiver component. To know the distance between the target and the sensor, the sensor calculates the amount of time required for sound emission to travel from transmitter to receiver. The calculation is done as follows:

D = 1/2 T * C
The T is the time measured in seconds and the C corresponds to sound speed = 343 measured in mts/sec

Ultrasonic Pin Diagram

This sensor has the next pins:

  • Vcc – This pin has to be connected to a power supply +5V.
  • TRIG – This pin is used to receive controlling signals from the Arduino board. This is the triggering input pin of the sensor
  • ECHO – This pin is used for sending signals to the Arduino board where the Arduino calculates the pulse duration to know the distance. This pin is the ECHO output of the sensor.
  • GND – This pin has to be connected to the ground.


The final circuit would look like this:

The circuit with connections

Now let's connect everything and we got this:

Final Circuit

Now we charge this basic code that makes the ultrasonic work and shows on the terminal the distance. The distance is shown thanks to an ecuation: distance = duration * 0.034 / 2. Duration is the total travel time of the ultrasound pulse (in microseconds). 0.034 cm/μs is the speed of sound in centimeters per microsecond. The product of duration and 0.034 gives the total distance traveled by the pulse in centimeters. Dividing by 2 adjusts this figure to represent the one-way distance from the sensor to the object.

The code of ultrasonic.

Finally for the ultrasonic, we got this:

Video of ultrasonic working

For my final project...

For my final project I need touch sensor that pass a material such as 3D filament on a 3D printed design. So for this I'm going to use a Touch sensor.

The TTP223 is a touch pad detector IC replicating a single tactile button. This touch detection IC is designed for replacing traditional direct button key with diverse pad size. Between it's features it has:

  • Input Voltage: 3.3V - 5.5V DC
  • Module size: 15mm x 11mm
  • Stable touching detection of human body for replacing traditional direct switch key.

This sensor has a simple communication method, only sends signal when detecting something and not send the signal when not detected.

The ttp223 touch sensor

Ttp223 effect when soldering parts

Now let's test how it works, using this code:

Code for test the touch sensor.

This is the circuit:

Circuit for touch sensor.

And the final result is:

Video of touch sensor turning on the leds on the PCB.

Finally I wanted to test if the touch sensor is capable of detect through a 3D printed piece, so I made a little box:

Box for testing.

And it works, this is going to be something that I'm going to use on my final project.

Checking if the touch sensor works through plastic.

Files