Beruflich Dokumente
Kultur Dokumente
Make your own customizable hmi in the app without the need of a computer, you can select from six
dierent objects (widgets): button, switch, led, display 7 segments, bar indicator and slider.
(https://play.google.com/store/apps/details?
id=com.casdata.hmicontrollerforarduino)
The Widgets
You can nd six dierent components (widgets) to interact with your Arduino, which are divided into two groups. The rst group are the
input widgets that are conform by:
1. Button: Is used with the variables pin-out and virtual-boolean-in. In the conguration box in the app, only requires a name tag and
the variable which is going to be associated.
2. Switch: Used the same variables like the button widget and it have the same conguration box.
3. Slider: It changes a variable of type int from a min value to a max value, it acts like a potentiometer. It's compatible only with the
virtual-int-in variable. In the conguration box, it requires to put the name tag, the min value, the max value and the variable to
associate.
The second group of widgets are the output widgets, these are:
1. Led: This widget turns on or o according to the state of the associated variable. The variables to associate are: pin-out, pin-in and
virtual-boolean-out. It only requires the variable to associate and a name tag.
2. Display 7 segments: It show an integer number from 0 to 9999, the associate variable is the virtual-int-out. It only requires the
variable to associate and a name tag.
3. Bar Indicator: This widget shows the state of a variable from a min to a max value, the associate variable is the virtual-int-out. In the
conguration box, it requires to put the name tag, the min value, the max value and the variable to associate.
Note: The input widgets sends data to the Arduino board and the output widgets reads data from the Arduino board.
Types of variables
The Hmi Controller use six dierent types of variables for the interaction between the application and the Arduino board, this variables
are:
1. pin-in: This variable represents a physical INPUT pin of the Arduino board. This variable is automatically declared when is used the
Arduino pinMode function in the sketch.
2. pin-out: It represents a physical OUTPUT pin of the Arduino board. This variable is automatically declared when is used the Arduino
pinMode function in the sketch.
3. virtual-boolean-in: It's a boolean variable used as an "IN" data from the app to the Arduino. It can be declared in the hmi system by
using the attachBooleanIn function in the sketch.
4. virtual-boolean-out: It's a boolean variable used as an "OUT" data from the Arduino board to the app. It can be declared in the hmi
system by using the attachBooleanOut function in the sketch.
5. virtual-int-in: It's an int variable used as an "IN" data from the app to the Arduino. It can be declared in the hmi system by using the
attachIntIn function in the sketch.
6. virtual-int-out: It's an int variable used as an "OUT" data from the Arduino board to the app. It can be declared in the hmi system by
using the attachIntOut function in the sketch.
Hmi.attachIntIn(intvariable, charletter);
The attachIntIn allows you to attach a variable of type int to the Hmi system, this variable it must be already declared in the Arduino
sketch and is used to read data from the Android device. The argument letter is a tag of type char for identify the int variable inside the
Hmi Controller app.
This function attach an Int variable to the Hmi system, this variable it must be already declared in the Arduino sketch and is used to write
data to the Android device. The argument letter is a tag of type char for identify the int variable inside the Hmi Controller app.
The attachBooleanIn is used for attach a variable of type boolean to the Hmi system, this variable it must be already declared in the
Arduino sketch and is used to read data from the Android device. The argument letter is a tag of type char for identify the boolean
variable inside the HMI Controller app.
The attachBooleanOut function attach a boolean variable to the Hmi system, this variable it must be already declared in the Arduino
sketch and is used to write data to the Android device. The argument letter is a char used as a tag for identify the boolean variable inside
the HMI Controller app.
In order to use the Hmi Controller with your Arduino board, you must implement one of the following functions at the end of your sketch:
Hmi.softSerial(SoftwareSerial mySerial): Is used when you're implementing a Bluetooth connection with the Arduino SoftwareSerial
library, this is recommended to be use when implementing the Arduino UNO and Arduino micro.
Hmi.hardSerial(HardwareSerial mySerial): Is used when you're implementing a Bluetooth connection with the Arduino
HardwareSerial library, this is recommended to be use when implementing the Arduino Mega.
Hmi.n Ethernet(Server myServer): Is used when you're implementing an Arduino Ethernet shield.
This functions transmits the data between the two devices, in other words, it allows the connection of your Arduino board and your
Android device.
Note 1: If in your code you're making a loop that ends when a specic variable or an input pin has changed, you must also include one of
this functions inside that loop.
The module use a serial communication with the Arduino so it can be connected in the serial ports that are between the pin 14 to pin 19
when using an Arduino Mega. On an Arduino Uno and Nano the serial pins are the pin 0 and pin 1. The adapter can also be connected in
other pins declared as serial pins with the Software Serial library.
4. Write or open a sketch with the HMI functions in it, there are some examples below that you can use.
6. Turn ON the Bluetooth in the Android device. In case that the Arduino Bluetooth module isn't paired with Android continue with the
next point , otherwise go to step number eight.
7. Go to the Bluetooth settings in the Android settings, make your Android visible to all nearby Bluetooth devices and tap the "search for
devices" button. The pairing password of the JY-MCU HC-06 module is 1234.
8. Open the HMI Controller app in the Android device, select "Bluetooth" in the type of connection dialog box and select your Arduino
Bluetooth module.
9. To add a widget go to Edit -> "Add widget" that's in the action bar, the "Edit" button looks like a pencil.
10. Once all the widgets are in place according to the desired design, tap the "Play" button to begin the connection.
6. When using the Ethernet functions in the sketch is important to set the IP address, the subnet or mask, the gateway and the MAC for
the Ethernet Shield, other things to keep in mind is the number of the port, this number must be set to the port number 23.
8. Open the HMI Controller app in the Android device, select "LAN (Ethernet Shield)" in the type of connection dialog box.
9. Set the IP address of the Arduino board, the same IP that was congured in the Arduino sketch.
10. To add a widget go to Edit -> "Add widget"that's in the action bar, the "Edit" button looks like a pencil.
11. Once all the widgets are in place according to the desired design, tap the "Play" button to begin the connection.
EXAMPLES
For an easy understanding of how to use the app with the Arduino IDE, there are three examples, each one with the Arduino .ino le and
the examples can be found in menu of the app.
(/uploads/4/3/6/0/43609407/arduino_pins_bluetooth.ino)
arduino_pins_bluetooth.ino
Download File
(/uploads/4/3/6/0/43609407/arduino_pins_bluetooth.ino)
Attaching and using the virtual int variables:
(/uploads/4/3/6/0/43609407/virtual_int_variables_bluetooth.ino)
virtual_int_variables_bluetooth.ino
Download File
(/uploads/4/3/6/0/43609407/virtual_int_variables_bluetooth.
(/uploads/4/3/6/0/43609407/virtual_boolean_variables_bluetoot
virtual_boolean_variables_bluetooth.ino
Download File
(/uploads/4/3/6/0/43609407/virtual_boolean_variables_bluet
Car example:
(/uploads/4/3/6/0/43609407/car.ino)
car.ino
Download File
(/uploads/4/3/6/0/43609407/car.ino)
Hmi Controller for Arduino example part 1
(/uploads/4/3/6/0/43609407/template_ethernet.ino)
(/uploads/4/3/6/0/43609407/template_bluetooth_serial.ino)
(/uploads/4/3/6/0/43609407/template_bluetooth_softwareseria
template_ethernet.ino template_bluetooth_serial.ino template_bluetooth_softwareserial.ino
Download File Download File Download File
(/uploads/4/3/6/0/43609407/template_ethernet.ino)
(/uploads/4/3/6/0/43609407/template_bluetooth_serial.ino)
(/uploads/4/3/6/0/43609407/template_bluetooth_softwarese