0% found this document useful (0 votes)
52 views

Commands For EV3-API: Initialization

The document provides commands and explanations for initializing, displaying text, waiting, reading sensor inputs, controlling motors and LEDs, and checking button states on the EV3 robot. It includes commands for initializing and closing EV3 functions, printing text to the LCD screen, reading sensor values, setting motor speeds, checking button presses, and setting LED patterns. Parameter types and values are explained for proper use of each command.

Uploaded by

Polina
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
52 views

Commands For EV3-API: Initialization

The document provides commands and explanations for initializing, displaying text, waiting, reading sensor inputs, controlling motors and LEDs, and checking button states on the EV3 robot. It includes commands for initializing and closing EV3 functions, printing text to the LCD screen, reading sensor values, setting motor speeds, checking button presses, and setting LED patterns. Parameter types and values are explained for proper use of each command.

Uploaded by

Polina
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Commands for EV3-API

Initialization:
command explanation
#include <ev3.h> including Header
InitEV3(); Initialization of all EV3-Functions
FreeEV3(); Closing of all EV3-Functions

Display:
command explanation
bool LcdClean(); Erase Display
LcdPrintf(<Color>,<Text>,…); Working like printf()

Help:
parameter type explanation value
<Color> char Color of text 1: black text
0: wihteteext with black
background
<Text> char* Pointer to text e.g. “Hello EV3“

Break:
command explanation
void Wait(<Zeit_ms>); Break code for a given time

Help:
parameter type explanation value
<Zeit_ms> unsigned time in ms MS_1…10 :1
long possible to use the given macros or type 10…100 :10
directly the value 50…500 :50
100…900 :100
SEC_1…10 :1
5…20 :5
30
MIN_1

Simón Rodriguez Perez, 2016


Inputs (Sensoren):
Commands:
command explanation
int setAllSensorMode(<Mode>, Allocate of the sensor types of all 4 ports in the correct
<Mode>,<Mode>,<Mode>); order (IN_1, IN_2, IN_3, IN4)
int readSensor(<Input>); Readout of the actual sensor data
int setIRBeaconCH(<Input>, <Channel>); Set Channel of the Beacon for Readout (default: Ch. 1 )

Help:
parameter type explanation value
<Input> int Input-Ports IN_1, IN_2, IN_3, IN_4
<Mode> char Name und Mode of the connected Sensors See next table
<Channel> int Channel of the Beacon. BEACON_CH_1,
Needed for: IR_SEEK and IR_REMOTE BEACON_CH_2,
BEACON_CH_3,
BEACON_CH_4

Sensor type:
Sensor <Mode> explanation return value
No Sensor NO_SEN No sensor to the port -1
connected
Touch sensor TOUCH_PRESS Return of state (2 states Not pressed: 0
possible) pressed: 1
Light sensor COL_REFLECT Return of the reflected light 0 to 100
intensities in %
COL_AMBIENT Return of room light intensities 0 to 100
in %
COL_COLOR Return of color 0: transparent
1: black
2: blue
3: green
4: yellow
5: red
6: white
7: brown
Sonar sensor US_DIST_MM Return of distance in mm 0 to 2550
Gyroscope GYRO_ANG Return of angle in ° -180 to 180
GYRO_RATE Return of gear rate in °/s -440 to 440
EV3 Infrared IR_PROX Return of distance in % (up to 0 (Near) to 100 (Far)
70cm)
IR_SEEK Position of the Beacon -25 to 25
IR_REMOTE Controlling EV3 with Beacon BEACON_OFF
BEACON_UP_LEFT
BEACON_DOWN_LEFT
BEACON_UP_RIGHT
BEACON_DOWN_RIGHT
BEACON_UP
BEACON_DIAG_UP_LEFT

Simón Rodriguez Perez, 2016


BEACON_DIAG_UP_RIGHT
BEACON_DOWN
BEACON_ON
BEACON_LEFT
BEACON_RIGHT
NXT Infrared NXT_IR_SEEKER 1 to 9

Outputs (Motoren):
Controlling:
command explanation
void OnFwdReg(<Output>, <Speed>); Forwards/backwards with given speed
void OnRevReg(<Output>, <Speed>);
void OnFwdSync(<Output>, <Speed>); synchronized forwards/backwards with given speed
void OnRevSync(<Output>, <Speed>); (only working with two motors)
void Off(<Output>); Switch off motors
void RotateMotor(<Output>, <Speed>, Rotate with given speed for a defined angle (Code stops
<Angle>); till the angle is reached)

Reading out:
command explanation
int MotorRotationCount(<Output>); Rotation angle of the motors in °
void ResetRotationCount(<Output>); Reset of rotation angle
char MotorPower(<Output>); Actual motor speed

Help:
parameter type explanation value
<Output> int Output-ports OUT_A, OUT_B, OUT_C,
OUT_D, OUT_AB, OUT_AC,
OUT_AD, OUT_BC, OUT_BD,
OUT_CD, OUT_ABC,
OUT_BCD, OUT_ABCD,
OUT_ALL
<Speed> char speed 0 to 100
<Angle> int angle in °

Simón Rodriguez Perez, 2016


Buttons und LED:
Functions for LED:
command explanation
void SetLedPattern(<Pattern>); Changing color of LED behind buttons
void SetLedWarning (<Value>); Activate/deaactivate of warning.
LED color cannot be changed while warning is set.

Functions for buttons:


command explanation
word ButtonWaitForAnyPress(<Zeit>); Waiting for button press for given time
bool ButtonIsUp(<Button>); Check if button is pressed or not
bool ButtonIsDown(<Button>); (1: true, 0: false)
void ButtonWaitForPress(<Button>); Waiting till a specific button is pressed
void Waiting till a specific button is pressed and released
ButtonWaitForPressAndRelease(<Button>);

Help:
parameter type explanation value
<Pattern> byte Color and modus of LED LED_BLACK (0)
LED_GREEN (1)
LED_RED (2)
LED_ORANGE (3)
LED_GREEN_FLASH (4)
LED_RED_FLASH (5)
LED_ORANGE_FLASH (6)
LED_GREEN_PULSE (7)
LED_RED_PULSE (8)
LED_ORANGE_PULSE (9)
<Value> bool Activate or deactivate 0: deactivate
1: activate
<Zeit> uint time in ms 0: for endless waiting
<Button> byte Name of button BTNEXIT, BTNRIGHT,
BTNLEFT, BTNCENTER,
BTNUP, BTNDOWN

Simón Rodriguez Perez, 2016

You might also like