12. Input Devices

This week, I...

Group assignment:

Group Assignment for week 12, Fab Puebla.

Choosing an INPUT device:

I decided to use a water level sensor since my final project might incorporate it. I want to understand how it works and explore what I can accomplish with it.

Testing the water sensor

For this assignment, I had to test the water level sensor before using it to read the water level of an aquarium, to ensure I understood how it works and how to integrate it effectively into my code. To accomplish this, I wrote some simple code to test the different water levels and observe how the sensor measured them.

I created a new file in Arduino IDE to do it. Here is the code I used:

From this test, I identified the following resistance values:

  • When 1/4 of the sensor is in the water, the resistance value is about 200.
  • When 1/2 of the sensor is in the water, the resistance value is around 310.
  • When the entire sensor is in the water, the resistance value goes up to 360.

This test helped me set the parameters for the values I would use in programming the sensor.

Programming the Water Sensor

Once I had completed the necessary tests, I proceeded to start coding. I decided to create a code that works with analog information from the sensor and defines four different water levels: Empty, Low, Medium, and High. I set different parameters so that if the water level was below, equal to, or above the set values, it would display one of the four levels on the serial monitor.

  • Empty: < 200
  • Low: > 100 <= 300
  • Medium: > 300 <= 330
  • High: > 330

Result