Introduction
The Pin State Monitor module is one of the most useful modules to debug your sensors and calibrate them for your program. This module provides you the real-time status of all the digital and analog pins.
Digital Pins Monitor
This shows the values of all the digital pins states. The state is shown in the form of ON or OFF, where ON state means the state of the pin is HIGH (5V) and OFF state means the state of the pin is LOW (0V).
Analog Pins Monitor
This shows the analog value of the voltage on the analog input pins. The value is shown from 0 to 1023, which is mapped to the voltage from 0 to 5V.
For example, is the value showing on the monitor is 512, then the voltage value will be approximately 5*(512/1023) = 2.5V.
Arduino IDE Functions
Header
To include the Pin Monitor module in the Arduino program, you have to include the following header:
#define CUSTOM_SETTINGS
#define INCLUDE_PINMONITOR_MODULE
After defining the above mention headers, you have to include the dabble library:
#include <Dabble.h>
You can download the zip of Dabble-Arduino (for evive, Uno, Mega, and Nano) or Dabble-ESP32 depending board you are using.
Enabling Bluetooth Communication
For evive and Arduino Mega, Uno and Nano
Dabble.begin(Baud_Rate);
Here Baud_Rate is the baud rate set for the Bluetooth module. With evive, you normally get 115200 baud rate modules.
For ESP32
Dabble.begin("Bluetooth_Name");
In place of Bluetooth_Name enter name that you want to keep for Bluetooth of ESP32. Default name given in the library is “MyEsp32”.
Refreshing the data
To refresh the data that the device has got from the mobile app, you have to use the following line of code:
Dabble.processInput();
Functions
If you want to refresh the pin state in your app, you have to use the following functions to do it:
- PinState.sendDigitalData() : This function sends all the digital pin state to the app.
- PinState.sendAnalogData() : This functions sends all the analog pin state to the app.
You have to add a delay between sending data to the app. This delay should be greater than 20 microseconds to achieve smooth functionality of the module.
PictoBlox (Scratch) Blocks
There is a stacked block named as “ enable pin state monitor” and its function is to enable the Pin State Monitor feature of Dabble.
Examples
In order to send the status of digital and analog pins of your board copy code as per your board from below mentioned board-wise codes or navigate to “Files>>Examples>>Dabble>>” and open “PinStateMonitor” for your board.
evive
Mega
Uno and NanoESP32
To enable the Pin State Monitor feature for the very first time, you have to upload the following script in upload mode:
The above script only works with evive, for working with Mega, Uno or Nano replace head block “when evive starts up” with start up block corresponding to your board and also start add set baud rate block. Pictoblox currently does not support ESP32; however, it will be added soon.