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 centre.
The Inputs Module of Dabble App has 3 input types:
- Slide Switch
- Tactical Switch
Each type has 2 inputs.
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.
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.
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.
You can access these control in the following ways:
Potentiometer: To use a potentiometer, you will need a reporter block “get potentiometer () value”. You can choose 1 or 2 from the drop-down of the block. It will return a value between 0 to 1023.
Slide Switch: To access a slide switch, you have to use a boolean block “is slide switch () ()?”
You can choose 1 or 2, Left or Right from the drop-down.
Tactile Switch: A boolean block “is tactile switch () pressed?” will enable you to access the tactile switch.
Controlling PWM pins using potentiometers.
Example Slide Switch
Setting digital pins using slide switches.
Example Tactile Switch
Setting digital pins using Tactile switches.
To include the LED Control module in the Arduino program, you have to include the following header:
After defining the above mention headers, you have to include the dabble library:
You can download the library from here:
Enabling Bluetooth Communication
To enable Bluetooth communication, you have to initialize serial communication using the following code:
Here Baud_Rate is the baud rate set for the Bluetooth module. With evive, you normally get 115200 baud rate modules.
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:
The following functions are available for the input module:
- Inputs.getvalue_Pot1(): This function returns the potentiometer value 1 reading from the app. The returned value ranges from 0 to 1023.
- Inputs.getvalue_Pot2(): This function returns the potentiometer value 2 reading from the app. The returned value ranges from 0 to 1023.
- Inputs.getStatus_SlideSwitch1(): This function returns the slide switch 1 state. These are the following possibilities for the returned value:
- 1 when the slide switch is in the left position.
- 2 when the slide switch is in the right position.
- 0 when the slide switch is in the center position.
- Inputs.getStatus_SlideSwitch2(): This function returns the slide switch 2 state.
- 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 when the switch is pressed.
- 0 when the switch is not pressed.
- Inputs.getStatus_TactileSwitch2(): This function tells whether the tactile switch 2 is pressed or not.