Lesson 2 Robot Coding
Lesson 2 Robot Coding
●
Learning the interface
●
Moving
●
Turning
●
Loops
EV3 vs Spike Prime
●
We’ll be using the EV3 Classroom software for demonstration
●
Programming blocks in Spike Prime are not exactly the same, but
are very similar
●
I’m sure you’ll figure it out! Let us know if you need help.
Code blocks
Block palette
Motors – Control one motor at a time
Movement – Control two motors to move the robot
Display / Light – Display words / pictures on the main brick
Sound – Play a sound
Events – Start a script when something happens
Control – Loops, conditions, etc
Sensors – Get values from sensors
Operators – Math and logic
Variable – Store information
My Blocks – Custom blocks that you create
Programming Screen
Download
Send program to robot. You can then
Download Run run it from the robot menu.
Run
Run the program on the robot
immediately
Try it out!
●
Run the program on your robot.
First Program!
Challenges
Run What happens when you...
Download ●
change the number of rotations?
●
change the speed?
●
change the “straight: 0” to some
other value?
●
set a negative number of rotations
(eg. “-1”)?
Turning
Run the code blocks below this
“when the program starts”
Spin turn
One wheel going forward and the
other going backwards
Challenges
Get your robot to turn 90 degrees
How many rotations do you need?
What about 180 degrees?
Challenges
Program your robot to
move in a square
Square movements
Solution
Repeated
Loops
Run the code blocks below this
“when the program starts”
●
Set the movement motors at the
start
●
“move straight: 0” makes robot
move forward
●
Negative rotation to make robot
move backwards
Summary
●
Move “right: 100” or “left: -100”
makes robot turn on the spot
●
Values less than 100 creates a
gradual turn
●
Loops makes the code inside
repeat the specified number of
times