Events

"Event" blocks in EV3 are like special buttons that you can program to make your robot do specific actions when certain events happen. They add a lot of fun and interactivity to your robot's behavior!

event-meaning

Build the entire robot by:

If you have not done so

IMG-2019 IMG-2018

We are going to explore these blocks:

event-meaning

-> "When the program begins": it's the most common used block.

-> We can also use the sensors to start the program, as long as it meet the condition.

-> The broadcast block are to send message from one code to the other.


The 5 buttons of the brick:

event-brick-intro

There are 5 buttons you can press and starts the program.

The "no" means: no button press (just like "when the program starts")

The "center" and "left" button

When "center" button is pressed

event BABY ROBOT

Notice that the video/image is x2 speed.

EVENT-CENTER-PRESSED

1- The robot wait for you press "center" buttom

2-Robot move forward 300 degrees at the speed of 30%

3- Motor A move 200 degrees clockwise at the speed of 20%

4-Robot move forward 400 degrees at the speed of 30%

5- Motor A move 100 degrees counter-clockwise at the speed of 20%

6-Robot move backward 300 degrees at the speed of 30%

7- Stop and Exit program

When "left" button is pressed

event BABY ROBOT (2)
3-event-left

1- The robot wait for you press "left" buttom

2-Robot move forward 1000 degrees, left wheel at the speed of -60% and right wheel at the speed of 0%

-> Robot make a pivot turn of 1000 degrees.


The sensors

Ultrasonic Sensor

event BABY ROBOT (1)
1-event-ultra

1- The robot wait for ultrasonic sensor sense "less than 15cm"

2-Robot move forward 1000 degrees, left wheel at the speed of -60% and right wheel at the speed of -20%

-> Robot make a pivot turn of 1000 degrees.

Touch Sensor + display

event BABY ROBOT (3)
4-event-face

1- The robot wait until touch sensor is "pressed"

2- Robot display robot "smile" face for 1 second

3- Robot display robot "wink" face for 1 second

4- Robot display robot "smile" face for 1 second

5- Robot display robot "wink" face for 1 second

6- Stop and Exit program


Broadcast

Remember this code from Control "wait" block?

Screenshot-2024-05-14-at-07-28-27

We are going to use broadcast.

Notice: you can change the name of the broadcast.

a waitss BABY ROBOT (2)

-> Broadcast named "broadcast1" is Motor A moves clockwise of 250 degrees at the speed of 75%

Screenshot-2024-05-14-at-07-31-13

1- Robot move 450 degrees forward at the speed of 50%

2- Robot wait for 1 second

3- Code broadcast receive message called "broadcast1"

which it's Motor A moves clockwise of 250 degrees at the speed of 75%

Observations: Why is "Event" important for programming?

Time for a quiz!

Question goes here

Challenge for you: color sensor in Event

event color

I want you to use:

Use Event block for color sensor

-> Sound blocks:

1- Color sensor reads "Green": say "green". Then, say "go"

2- Color sensor reads "Red": say "red". Then, say "stop"


-> Robot moves backward at speed of 40%

-> Stop and exit program

5-event-color-sound

1- The robot wait until color sensor read "green"

2- Robot say "Green". And then say "Go"

3-Robot "starts moving" backward at the speed of 40%

4- Until color sensor read "red"

5- Robot stop moving

6- Robot say "Red". And then say "Stop"

7- Stop and Exit program