[IOIO] Command Code on App Inventor for IOIO Inventor

 

        ** Please check on IOIO Inventor’s package name. If you has downloaded on “com.inex.ioioappinventorinter” package name, please change from

  • “com.inex.ioioappinventor” to “com.inex.ioioappinventorinter”
  • “com.inex.ioioappinventor.IOIOCommand” to “com.inex.ioioappinventorinter.IOIOCommand”

 

        For command on using the IOIO Inventor application are divided into 5 types as follows.

• Digital Command

 

DigitalRead

DigitalWrite

 

• Analog Command

 

AnalogRead

AnalogWrite

 

• Sound Command

 

Sound

 

 

• Motor Command

 

MotorForward

MotorBackward

MotorLeft

MotorRight

Motor

AO

MotorStop

MotorStopAll

 

• Servo Command

 

Servo

 

        The pin of the IOIO board will have different properties according to the table.

 

        Therefore, the user must ensure that pin is support with that command or not.

 

 

 

Digital Command

DigitalRead

        Command to read digital signal from IOIO board‘s pin. Having two values (True or False)

DigitalRead,Pin

        Pin: A pin of the IOIO board to be used for read digital signal, configurable from 1 to 49

        For example, the command to read digital signal from pin 36

DigitalWrite

        Command to set digital signal to IOIO board’s pin. Having two values (True or False)

DigitalWrite,Pin,State

        Pin: A pin of the IOIO board to be used for set digital signal, configurable from 1 to 49 State: a state of pin that needs to set to True or False .

 

        For example, the command to set digital signal to pin 0 to False

 

        For example, the command to set digital signal to pin 0 to True

 

 

 

Analog Command

AnalogRead

        Command to read analog signal from IOIO board’s pin. Having values from 0 to 1023 (0 = 0V, 1023 = 3.3V)

AnalogRead,Pin

        Pin:  A pin of the IOIO board to be used for read analog signal, configurable from 31 to 46

        For example, the command to read analog signal from pin 34

 

 

AnalogWrite

        Command to set analog signal to IOIO board’s pin. Having values from 0 to 100 (0 = 0V, 100 = 3.3V)

AnalogRead,Pin,Percent

        Pin: A pin of the IOIO board to be used for set analog signal, configurable from 0, 2-7, 9-14, 27-32 and 34-40

        Percent: a percent of analog signal to be determined (If percent is 50 that means 50% of 3.3V)

.

        For example, the command to set analog signal to pin 4 by 30% (3.3 x 30 / 100 = 0.99V)

 

 

Sound Command

Sound

        Command to generate sound on piezo speaker by piezo speaker must be connected to IOIO board’s pin. The user can configure the frequency and duration of sound.

Sound,Pin,Frequency,Duration

        Pin: A pin of the IOIO board to be used for generate sound, configurable from 2-7, 9-14, 27-32 and 34-40

        Frequency: Frequency of sound that will be generated. (Hz)

        Duation: Duration of sound that will be generated. (Millisecond)

        For example, the command to generate sound to pin 27 by 800 Hz for 500 milliseconds.

 

Motor Command

        Motor command is a command to be used for IOIO-Robotic Activity board which have 6-channels motor controller by fixing pin position which connected to the motor driver module. In order to be connected to the motor driver board which is not IOIO-Robotic Activity board, you must be connected to the IOIO board as follows.

        For MotorForward, MotorBackward, MotorLeft, MotorRight and AO command are command for motor channel 1, 2, 5 and 6 (Movement Motors) because these are command to drive motor for use with 2-wheel or 4-wheel drive robot. The user can use motor on channel 3 and 4 for use otherwise.

.

MotorForward

        Command to drive 4 movement motors for forward movement.

MotorForward,Speed

        Speed: Speed of motor, configurable from 0 to 100 . For example, the command to move forward with 60% movement speed

 

 

 

MotorBackward

        Command to drive 4 movement motors for backward movement.

MotorBackward,Speed

        Speed: Speed of motor, configurable from 0 to 100

.

        For example, the command to move backward with 60% movement speed

 

 

 

MotorLeft

        Command to drive 4 movement motors for turn left movement.

MotorLeft,Speed

        Speed: Speed of motor, configurable from 0 to 100 . For example, the command to turn left with 50% movement speed

 

 

 

MotorRight

        Command to drive 4 movement motors for turn right movement.

MotorRight,Speed

        Speed: Speed of motor, configurable from 0 to 100 . For example, the command to turn right with 50% movement speed AO

        Command to stop 4 movement motors.

AO

        For example, the command to stop.

 

Motor

        Command to control motor by each motor.

Motor,Number,Speed

        Number: Channel number of motor that user want to control Speed: Speed of motor, configurable from -100 to 100 . For example, the command to drive motor channel 1 to move forward with 50% movement speed

        For example, the command to drive motor channel 6 to move backward with 70% movement speed

 

MotorStop

        Command to stop motor by each motor.

MotorStop,Number

        Number: Channel number of motor that user want to stop

 

        For example, the command to stop motor channel 3

 

MotorStopAll

        Command to stop all of 6 channel motors.

MotorStopAll

        For example, the command to stop all motor

 

 

 

Servo Command

Servo

        Command to control servo motor. Define angle of servo motor axis in degree unit.

Servo,Pin,Angle

        Pin: A pin of the IOIO board to be used to control servo motor Angle: Angle of servo motor axis in degree unit, configurable from 0 to 180 degree .

 

        For example, the command to move servo motor axis to 90 degree (Middle), by servo motor is connects on pin 48.

 

 

 

Receive data from IOIO Inventor

        Sometimes the user likes to get some data from IOIO board such as DigitalRead and AnalogRead command. Which both command are get data the same. This is normally Activity Starter block for IOIO Inventor.

 

 

        To get data, we will receive data from Activity Starter on “when ActivityStarter AfterActivity” (Depending on Activity Starter name) block.

 

 

        And data will be return in “Result Type” block. Then choose ActivityStarter1 (Depending on Activity Starter name) block and drag “ResultType” block to workspace.

 

        For example, I defined the variable which name is “variable” and initial value to 0. When I call ActivityStarter1 to read some data, “when ActivityStarter1 AfterActivity” will work and send data that I need. I stored that data on my variable.

 

 

        This is example program to read digital signal from pin 1. The code is as follows.

 

 

        Don’t use command to read many data likes this. It won’t work.

 

 

        In this example, I want to read digital signal from pin 1 and read analog signal from pin 31 by press button to read. I would have created two activities and two procedures with difference command. But I call them in the same time, but It make a problem when data returned, because application can’t recognized the data returned. So I had to read first data then read next data after first data was received as follows.

 

 

IOIO Inventor instructions

  • The user can open the IOIO Inventor from application which built from App Inventor directly. But I recommend user to open the IOIO Inventor before using.
  • Any command for the IOIO Inventor will take 100-200 milliseconds to execute.
  • Close the IOIO  Inventor by touch application message on notification bar.
  • Any problem on connection, close the IOIO Inventor. Then open it again. If connecting via Bluetooth, restart Bluetooth too.

Related Articles

        [IOIO board] How does IOIO Inventor work?

        [IOIO board] How to use IOIO Inventor?

Facebook Comments Box