Home » Programacion » Facilino » Facilino Ejemplo » Reading a Potentiometer with Facilino

Reading a Potentiometer with Facilino

In this post, we show a simple example for reading an analog input with Facilino. The analog input value is mapped into a value between 0 and 100 and this will control the integrated LED of Arduino Nano, based on its value.

The aim of this example is to introduce analog input measurements using Facilino. Although this example is based on a potentiometer, most of sensor provide an analog output as their interface with a signal that varies between 0 and 5V, which means that can be read with Arduino when connected to an analog input. Therefore, the concepts learn in this example with the potentiometer can be extrapolated to other devices.

Analog inputs, in Arduino, return a value between 0 and 1023 which corresponds to the voltage (the value 1023 corresponds to 5V). Here, we will map the read value so that the value will be expressed in percentage.

Circuit

Here we show the required circuit to follow this example using Arduino Nano. The potentiometer is connected to analog input A0 of Arduino Nano.

Facilino

The aim of Facilino’s program is to regulate the integrated LED based on the potentiometer value. In this sense, if the value is higher than 80% the LED will be ON, while if it is lower than 20% the LED will be OFF. At intermediate values, the LED will blink with a frequency of 1Hz (500ms ON and 500ms OFF). The value measurements will be shown on the console every 500ms when ON or OFF and every 1000ms when blinking.

Here, you can find the solution of the example: