Page tree
Skip to end of metadata
Go to start of metadata

 

 

 

Content

> back

Index:

 

 

 

 

 

Sample programs

In this section we show you how NEPO programms can be developed to solve simple and also more difficult tasks. For each program, the following categories are indicated:

Description:

Table:

  • robot
  • motors
  • sensors
  • block category
  • difficulty (easy, middle, diffiuclt)
  • tip

Result:


 

 

Driving a square

Description: To make the robot drive a square is a popular exercise. The difficulty is not here in the programming per se, but rather in the precise adjustment of the rotations.

RobotMotorsSensorsBlock categoryDifficultyTipSimulation

EV3

2 large motorsnoBeginnereasyThe parameters must be adjusted depending on ground.Its ideal to test within the simulation environment »drawing scene«

Result: Your robot drives a square.


 


 

Driving a square using loop

Description: To make the robot drive a square is a popular exercise. The difficulty is not here in the programming per se, but rather in the precise adjustment of the rotations. There are two big advantages by using a loop:

  1. Your program becomes more clearer
  2. If you have to adjust your program you only have to do that in two blocks instead of eight blocks without using a loop
RobotMotorsSensorsBlock categoryDifficultyTipSimulation

EV3

2 large motorsnoBeginnereasyThe parameters must be adjusted depending on ground.Its ideal to test within the simulation environment »drawing scene«

Result: Your robot drives a square.

 

 

Cornering

Description: To let your robot drive a curve is almost needed in any program for mobile robots. There are several ways to drive a curve. We show you a example witch uses two different velocities within two blocks for the two motors (standard motors are in EV3 motor B and C motor) .

RobotMotorsSensorsBlock categoryDifficultyTipSimulation

EV3

2 large motorsnoBeginnermiddleThe radius of the curve is determined by the ratio of the different speeds between the motor B and CIts ideal to test within the simulation environment »drawing scene«

Result: Your robot drive a curve.

 


 


 

Controlled program termination

Description: Often you develop a program, run this at your robot and after the robot starts moving you notice that it doesnt stop. To terminate the program on the robot you can push the dark gray button on the EV3 brick along with underlying "down key". Since this is not an "elegant way" to end your program, we will show you how to program a controlled program termination.

RobotMotorsSensorsBlock categoryDifficultyTipSimulation

EV3

noEV3 butonsexpertmiddleYou can use other sensors e.g. the touch sensor (as a kind of emergency stop).not possible (so far)

Result: Your robot shows a Roberta on the display until you press the enter (dark grey) button on the EV3 brick.


 


 

LED status display

Description: Often you develop a program, run this at your robot and after the robot starts moving you notice that it doesnt stop. To terminate the program on the robot you can push the dark gray button on the EV3 brick along with underlying "down key". Since this is not an "elegant way" to end your program, we will show you how to program a controlled program termination.

RobotMotorsSensorsBlock categoryDifficultyTipSimulation

EV3

nocolor sensorbeginnermiddleNot only sensors like the color sensor and the ultrasonic sensors can be displayed, also (parameter) values, or calculations can be displayed.Within the simulation environment there is the possibility to show all the status information

Remember to specify the sensor used in your robot configuration within the Open Roberta Lab.

Result: The measured ambient light by the color sensor remains displayed in EV3 display until the (dark gray) enter EV3 button has been pressed.

 

 


 


 

Own blocks, macros, methods

Description: Our programming languague NEPO contains the possibility to program own functions in other programming languages also known as own blocks or macros.

RobotMotorsSensorsBlock categoryDifficultyTipSimulation

EV3

2 large motorsnoexpertmiddleAfter you have given your function a name, the block appears category functions.not possible (so far)

Each name of a function has to begin with lowercase!

Result: Your robot drives a square each time you use the function "driveSquare" in your program.

 

 


 


 

Line follower

Description: You want your robot to follow a line. We show you a first program that which led your robot follow a (black) line. The idea behind this program is that the robot moves "lurches" along the white / black edge. When the robot is on the "white", then it moves to the left otherwise (it is on "black"), it moves to the right. As a result, the robot moves forwards.

 

RobotMotorsSensorsBlock categoryDifficultyTipSimulation

EV3

2 large motorsColor sensorexpertmiddelIt is important for this purpose to determine a so-called threshold. In our example, this is "15". To maintain this we have used the state-sensor display. Its very helpful to test this program within in the environment »Simple Scene« and/or »Roberta Scene«
BlocksLoop with break, Move, Color sensor, Logic, If-then-else

Result: Your Robot follows a (black) line.


 


 

Theorem of Pythagoras

Description: Of course you know the theorem of Pythagoras from math classes: a²+b²=c². In the following programming example we show how to use the theorem of Pythagoras to control your robot for driving an exact distance.

First we transform the formula to receive the length of c which results to c = √a²+b². Since there is no mathematical block for square root we use the exponent function with parameter 0,5: c = (a²+b²)^0,5.

Task: The (simulated) robot shall drive to the position (40, 40).

Solution: Your robot has to drive the exact distance of 56,57 cm using an angle of 45°. How do we get the distance of 56,57 cm? Using the theorem of Pythagoras we know a = 40 and b = 40. Squaring a and b and then adding them leads to  ((40)²+(40)²). Now we have to take the square root by using the exponent function with parameter 0,5. So our formula for the driving distance is this: ((40²)+(40²)^0,5) = 56,57.

This formla can easily be installed by using the appropriate Math blocks. Just click the animation on the right to see the complete program.

 

Experts solution: Obviously also the angle of 45° may be calculated. The solution will be presented later on.

RobotMotorsSensorsBlock categoryLevelTipSimulation

1xEV3

2D-Sim

2 large motorsno sensorsBeginnersmedium

Test in the simulation window.

A desk pad with coordinates may be very helpful.

The test environment "table" fits best to test the program.
BlocksMath

Result: Your Robot drives to the coordinate (40.40)


  • No labels