Communication ECA Phase IV Class 6: Cruise Control 20181017

During this lesson, the students gain a good understanding of the Variable Block. The students will use this information to create a cruise control feature for their wheeled robots. The students will utilize two Touch Sensors to control and maintain the speed of their robot. The students will need to program their robot so that, once moving, it can be sped up by pressing the Touch Sensor. Code blocks for controlling the Touch Sensor (wait) should be placed inside a loop.

The Variable Block is a programming block that can store data (text, logic, a numeric, or arrays), which can be overwritten at any time while the program is running. This block has to be read and then written to, using the Math, Text, or Array Operations Blocks.

Program 1: Increase Speed with Variable

  1. Start the program.
  2. Create a Variable Block called “Speed” and enter a value of 0.
  3. If the Touch Sensor is pressed:
    1. Read the variable called “Speed”
    2. Add 10 to the read value
    3. Write the result in the variable called “Speed”
    4. Read the variable called “Speed”
    5. Start motors B and C at a speed set to the value stored in the variable called “Speed”
  4. ELSE
  5. (Do nothing)
  6. Repeat steps 3a to 3e forever.

Program 2: Increase and Decrease Speed with Variable

With the first program written and the robot accelerating when the Touch Sensor is pressed, the students would extend the program to slow the robot down.

One solution could be to have a second unlimited loop similar to the loop used in the first programming exercise. This loop would use a different Touch Sensor port (another sensor added). The Math Block would be changed to subtract rather than add.

  1. Start the program.
  2. Create a Variable Block called “Speed”, enter a value of 0, and start two tasks.

TASK 1

  1. If Touch Sensor 1 is pressed:
  2. Read the variable called “Speed”
  3. Add 10 to the read value
  4. Write the result in the variable called “Speed”
  5. Read the variable called “Speed”
  6. Start motors B and C at a speed set to the value stored in the variable called “Speed”

ELSE

(Do nothing)

  1. Repeat steps 3a to 3e forever.

TASK 2

  1. If Touch Sensor 2 is pressed:
  2. Read the variable called “Speed”
  3. Subtract 10 from the read value
  4. Write the result in the variable called “Speed”
  5. Read the variable called “Speed”
  6. Start motors B and C at a speed set to the value stored in the variable called “Speed”

ELSE

(Do nothing)

  1. Repeat steps 5a to 5e forever.**

Program 3: Increase and Decrease Speed with Variable and Display

With the wheeled robot now accelerating and decelerating at the touch of a button (or two), students can extend their programming to show how fast their robots are moving. Students will use the Display Block to show this value in the Variable Block.

A new skill to be learned in this lesson is the creation of a My Block. Two of these can be seen in the solution below. My Blocks allow users to create subroutines of programs they have already written. In the case below, we have taken the acceleration and deceleration loops and created My Blocks from these programs. There are two reasons to do this: first to save space, and second to allow these subroutines to be reused in other programs.

  1. Start the program.
  2. Create a Variable Block called “Speed”, enter a value of 0, and start three tasks.

TASK 1

  1. Start My Block “Acceleration”.

TASK 2

  1. Start My Block “Deceleration”.

TASK 3

  1. Read the variable called “Speed”.
  2. Display the value stored in the variable called “Speed”.
  3. Repeat steps 5 and 6 forever.

Communication ECA Phase IV Class 3: Automatic Parking 20180926

In this class, we will achieve an autonomous parking. Frist, we construct the Robot Educator base model, which is a basic wheeled robot.
Program 1: Three Point Turn

1. Start the Program
2. Turn the driving base and stop after 1.5 seconds.
3. Turn the driving base left and stop after 1 second.
4. Move the driving base forward for 3 seconds.

Program 2: Parallel Parking

1. Start the Program.
2. Drive forward in a straight line at the desired speed.
3. Wait for 1 second.
4. Reverse motor rotation while turning for 1.5 rotation.
5. Reverse motor rotation while turning the other way for 1.5 rotation.
6. Drive backward in a straight line for 0.5 rotation.
7. Drive forward in a straight line for 1 rotation.

Program 3: Parallel Parking with Simulating Reverse Gear and Reverse Warning lights

1. Start the Program.
2. Drive forward in a straight line at the desired speed.
3. Wait for 1 second.
4. Turn light on (reverse light).
5. Reverse motor rotation while turning for 1.5 rotation.
6. Reverse motor rotation while turning the other way for 1.5 rotation.
7. Drive backward in a straight line for 0.5 rotation.
8. Drive forward in a straight line for 1 rotation.

After finishing each program, make sure to check the following building before sending command to the wheeled robot: Are the wires correctly connected from the motors to ports B and C? Are the wheels correctly installed? Are the wheels rotating freely?

Communication ECA Phase IV Class 2: Programming Basics 20180919

In the second class, we continued talking the main programming blocks in the EV3 software and the hardware communications. The programming blocks include three categories: Action, Flow control, and Sensors. The Action includes all action related blocks such as the motor, motion mode, and sound and light of the brick. The Flow control includes start, delay, loop, and switch blocks. The Sensors include color sensors, ultrasonic sensors, gyroscope sensors, and touch sensors.

The first program we covered was the motor control.

The program starts by a “start” block in the “flow control” category, follows by a “large motor” block in the “action” category, then a “wait” block in the “flow control” category. The differences among three motor control blocks come from the first button, from where we can choose the control mode of the motor. The five control modes are literally intuitive. The second button controls the power input, the number can be both positive and negative, which can make the motor rotate and clockwise contraclockwise.  The third one depends on the choice of the first control mode. For example, in the first “large motor” block, we picked “on for rotations”, power to “50”, and “1”. The block controlled the motor to rotate 1 clockwise circle. The “wait” block is nothing but to control the motor to stop for 1 sec.

The second program we did was the touch sensor.

As the last program, it starts by a “start” block in the “flow control” category, follows by a “wait” block in the “flow control” category, then a “sound” block in the “action” category. The “wait” block is very powerful and can be used to control all sensors by choosing from the first button list. The reason we used a “wait” block instead of the “touch sensor” in the “sensor” category is that the program pipeline needs to be paused until the sensor get triggered after a time delay. Due to the fact that the time is not determined until the sensor gets triggered, thus we cannot use set a determined time as same as the first motor control program. The “sound” block was activated when the touch sensor was triggered and gave a sound “Ouch”, which can be picked in the upper right button list.

Play2Learn Education