Input Module

Inputs

This module allows you to provide analog and digital inputs.

You can provide analog input using the knobs in the extreme left by sliding the white bar in the clockwise direction.

You can provide digital input using the push buttons (momentary/tactile switches) in the extreme right and the slide switches (ON-OFF-ON) in the center.

Introduction

The Inputs Module of Dabble App has 3 input types:

  1. Potentiometer
  2. Slide Switch
  3. Tactical Switch

Dabble Inputs OFF

Each type has 2 inputs. 

Potentiometer

The potentiometer is the first input type from left. It works similar to a real potentiometer, by providing a variable output value between 0 to 1023. You can change the value by rotating it. The value is sent to the hardware device when the potentiometer is moved.

Dabble Inputs Left ON

Slide Switch

The Slide Switch is the second input type from left. It has 3 states – Left, Right, and Off. By default when the module is opened the slide switch is in Off state. You can change the state of the slide switch by clicking on the desired state. 

At all time only one state will be active and the other two states will be inactive. The state of the slide switch is sent to Arduino, only when there is a change in the active position.

Tactile Switch

The tactile switch is the third and the last module in the Input module. It senses whether the user has pressed on the switch or not. It a momentary-type switch. 

Dabble Inputs Left

Arduino IDE Functions

Header

To include the Inputs module in the Arduino program, you have to include the following header:

#define CUSTOM_SETTINGS

#define INCLUDE_DABBLEINPUTS_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 on the board you are using.

Enabling Bluetooth Communication

To enable Bluetooth communication, you have to initialize serial communication using the following code:

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

The following functions are available for the input module:

  1. Inputs.getvalue_Pot1(): This function returns the potentiometer value 1 reading from the app. The returned value ranges from 0 to 1023.
  2. Inputs.getvalue_Pot2(): This function returns the potentiometer value 2 reading from the app. The returned value ranges from 0 to 1023.
  3. Inputs.getStatus_SlideSwitch1(): This function returns the slide switch 1 state. These are the following possibilities for the returned value:
    1. 1 when the slide switch is in the left position.
    2. 2 when the slide switch is in the right position.
    3. 0 when the slide switch is in the center position.
  4. Inputs.getStatus_SlideSwitch2(): This function returns the slide switch 2 state.
  5. Inputs.getStatus_TactileSwitch1(): This function tells whether the tactile switch 1 is pressed or not. These are the following possibilities for the returned value:
    1. 1 when the switch is pressed.
    2. 0 when the switch is not pressed.
  6. Inputs.getStatus_TactileSwitch2(): This function tells whether the tactile switch 2 is pressed or not.

PictoBlox (Scratch) Blocks

You can access the controls of Inputs in the following ways:

Potentiometer: To use a potentiometer, you will need a reporter blockget potentiometer () value”. You can choose 1 or 2 from the drop-down of the block. It will return a value between 0 to 1023.

get potentiometer value

Slide Switch: To access a slide switch, you have to use a boolean blockis slide switch () ()?

You can choose 1 or 2, Left or Right from the drop-down.

is slide switch pressed

Tactile Switch: A boolean block “is tactile switch () pressed?” will enable you to access the tactile switch.

is tactile switch pressed

evive Notes Icon
Note: When you are using this module with Arduino Uno, Mega, and Nano,  you have to set the Bluetooth baud rate to the baud rate of the Bluetooth module to have proper communication between the board and the module. To set the baud rate you have to use set bluetooth baud rate to () block.

set bluetooth baud rate to

Examples

Click here to view Arduino IDE Example for Input Module

This example code prints the current state of all the potentiometers, slide switches and tactile switches on Serial Monitor using the functions explained above. Board wise code is given below. You can also access the code by navigating to “File>>Examples>>Dabble>>” and selecting “Inputs” example as per your board. 

evive

Arduino Mega, Uno, and Nano

ESP32

Click here to view PictoBlox (Scratch) Example for Input Module

Example Potentiometer

Controlling PWM pins using potentiometers.

potentiometer dabble example

Example Slide Switch

Setting digital pins using slide switches.

Example Tactile Switch

Setting digital pins using Tactile switches.

is tactile switch example

 Depending upon your board type you can use different head blocks and along with it you also have to use “set bluetooth baudrate” as well, whereas rest of the script remains same. Currently, PictoBlox supports evive and Arduino Uno, Nano, and Mega boards. Support for ESP32 board will be added soon.

Projects

All articles loaded
No more articles to load

Leave a Reply

Close Menu
×

Cart