Introduction
Pin State monitor is included in the evive menu. It shows the state of all the digital and analog pins on evive. It shows the output as high or low for digital pins and analog value for analog pins. The pins are displayed in tabular form on the evive screen.
There are 40 digital pins in evive and 16 analog pins. Different colors are used to show the pin no. and its’ respective output.
Working
There is a function named digitalRead in library screen implementation.h in evive. It reads the state of digital pins in evive. In digital pins, there are 15 PWM pins whose state is determined first by a function called to turn off PWM in digitalRead which turns off PWM before the reading pin. After this, it reads the pin and returns high if pin output is high and low if pin output is low. turnOffPWM uses standard(AVR) methods for setting, or clearing, bits in PORT.
Then the lcd_digital_pin_state_monitor_late() function prints all this on the screen. It uses for loop to set lcdCursor and print all the pins. Similarly, analog pins are also printed. The digitalRead returns high when the if condition *portInputRegister(port) & bit is true. portInputRegister returns an input port register of the specified port. bit = digitalPinToBitMask(pin) which returns the bit mask of a specified pin.
Example (Debugging and Checking Digital Sensors)
Suppose, you have an IR sensor to detect a ball passing through a tube. Most of the sensors have an adjustment screws/potentiometer or you need to adjust the distance where the sensor is mounted from the ball. You can connect the sensor output to any Pin on evive and see the status of IR sensor on Pin State Monitor.
Example (Debugging and Calibrating Analog Sensors)
Suppose, we want to find a cutoff or maximum and minimum reading of an analog sensor like a Joystick or Flex sensor. We can move the thumbstick and take the readings from the Analog State Monitor. No need to make such a program, evive is there for you! 😉
Conclusion
Pin State Monitor is a great tool to debug and calibrate digital and analog sensors. It displays the state of all the digital and analog pins on evive in tabular form and helps you to identify any errors in the connections easily. With Pin State Monitor, you can also check the maximum and minimum readings of analog sensors like Joystick or Flex sensor.