ev3 micropython lesson 2 · ev3 micropython lesson 2 by stempowering girls stempoweringgirls.org....
TRANSCRIPT
![Page 1: EV3 Micropython Lesson 2 · EV3 Micropython Lesson 2 By STEMPowering Girls stempoweringgirls.org. Review Last week, we learned how to make the robot move forward and backwards, degrees](https://reader036.vdocuments.us/reader036/viewer/2022090606/605c5f017b1bf2425c664680/html5/thumbnails/1.jpg)
EV3 MicropythonLesson 2
By STEMPowering Girlsstempoweringgirls.org
![Page 2: EV3 Micropython Lesson 2 · EV3 Micropython Lesson 2 By STEMPowering Girls stempoweringgirls.org. Review Last week, we learned how to make the robot move forward and backwards, degrees](https://reader036.vdocuments.us/reader036/viewer/2022090606/605c5f017b1bf2425c664680/html5/thumbnails/2.jpg)
Review
Last week, we learned how to make the robot move forward and backwards, degrees
and rotations, and different types of turns.
STEMPowering Girlshttps://stempoweringgirls.org
![Page 3: EV3 Micropython Lesson 2 · EV3 Micropython Lesson 2 By STEMPowering Girls stempoweringgirls.org. Review Last week, we learned how to make the robot move forward and backwards, degrees](https://reader036.vdocuments.us/reader036/viewer/2022090606/605c5f017b1bf2425c664680/html5/thumbnails/3.jpg)
IF Statements
STEMPowering Girlshttps://stempoweringgirls.org
![Page 4: EV3 Micropython Lesson 2 · EV3 Micropython Lesson 2 By STEMPowering Girls stempoweringgirls.org. Review Last week, we learned how to make the robot move forward and backwards, degrees](https://reader036.vdocuments.us/reader036/viewer/2022090606/605c5f017b1bf2425c664680/html5/thumbnails/4.jpg)
If Statements
If statements check if the condition(s) are true and proceed
as such. If the condition is true, then the computer will
run whatever is in that statement.
STEMPowering Girlshttps://stempoweringgirls.org
![Page 5: EV3 Micropython Lesson 2 · EV3 Micropython Lesson 2 By STEMPowering Girls stempoweringgirls.org. Review Last week, we learned how to make the robot move forward and backwards, degrees](https://reader036.vdocuments.us/reader036/viewer/2022090606/605c5f017b1bf2425c664680/html5/thumbnails/5.jpg)
While Loops
STEMPowering Girlshttps://stempoweringgirls.org
![Page 6: EV3 Micropython Lesson 2 · EV3 Micropython Lesson 2 By STEMPowering Girls stempoweringgirls.org. Review Last week, we learned how to make the robot move forward and backwards, degrees](https://reader036.vdocuments.us/reader036/viewer/2022090606/605c5f017b1bf2425c664680/html5/thumbnails/6.jpg)
While Loops
While loops run the code inside them over and over again until the condition(s) are turned false.
STEMPowering Girlshttps://stempoweringgirls.org
![Page 7: EV3 Micropython Lesson 2 · EV3 Micropython Lesson 2 By STEMPowering Girls stempoweringgirls.org. Review Last week, we learned how to make the robot move forward and backwards, degrees](https://reader036.vdocuments.us/reader036/viewer/2022090606/605c5f017b1bf2425c664680/html5/thumbnails/7.jpg)
Brick Buttons
STEMPowering Girlshttps://stempoweringgirls.org
![Page 8: EV3 Micropython Lesson 2 · EV3 Micropython Lesson 2 By STEMPowering Girls stempoweringgirls.org. Review Last week, we learned how to make the robot move forward and backwards, degrees](https://reader036.vdocuments.us/reader036/viewer/2022090606/605c5f017b1bf2425c664680/html5/thumbnails/8.jpg)
Brick ButtonsThe buttons on the ev3 brick can be used to maneuver around the menus while a program isn’t running but they can also be used in the program itself. The robot can detect when a button is pressed and respond accordingly.
STEMPowering Girlshttps://stempoweringgirls.org
![Page 9: EV3 Micropython Lesson 2 · EV3 Micropython Lesson 2 By STEMPowering Girls stempoweringgirls.org. Review Last week, we learned how to make the robot move forward and backwards, degrees](https://reader036.vdocuments.us/reader036/viewer/2022090606/605c5f017b1bf2425c664680/html5/thumbnails/9.jpg)
Brick ButtonsEach of the 5 buttons in the center of the brick are named according to their position. The button on the far left is called Button.LEFT, the one in the center is called Button.CENTER, and so forth.
STEMPowering Girlshttps://stempoweringgirls.org
![Page 10: EV3 Micropython Lesson 2 · EV3 Micropython Lesson 2 By STEMPowering Girls stempoweringgirls.org. Review Last week, we learned how to make the robot move forward and backwards, degrees](https://reader036.vdocuments.us/reader036/viewer/2022090606/605c5f017b1bf2425c664680/html5/thumbnails/10.jpg)
BRick Buttons
If you needed to check whether a certain button is pressed in an if/while loop:
if Button.LEFT() in brick.buttons():
STEMPowering Girlshttps://stempoweringgirls.org
![Page 11: EV3 Micropython Lesson 2 · EV3 Micropython Lesson 2 By STEMPowering Girls stempoweringgirls.org. Review Last week, we learned how to make the robot move forward and backwards, degrees](https://reader036.vdocuments.us/reader036/viewer/2022090606/605c5f017b1bf2425c664680/html5/thumbnails/11.jpg)
Now Try it Yourself!Use the Up to travel forward 1 rotation and the down button
to travel Backward 1 Rotation
STEMPowering Girlshttps://stempoweringgirls.org
![Page 12: EV3 Micropython Lesson 2 · EV3 Micropython Lesson 2 By STEMPowering Girls stempoweringgirls.org. Review Last week, we learned how to make the robot move forward and backwards, degrees](https://reader036.vdocuments.us/reader036/viewer/2022090606/605c5f017b1bf2425c664680/html5/thumbnails/12.jpg)
Motor Sensors
STEMPowering Girlshttps://stempoweringgirls.org
![Page 13: EV3 Micropython Lesson 2 · EV3 Micropython Lesson 2 By STEMPowering Girls stempoweringgirls.org. Review Last week, we learned how to make the robot move forward and backwards, degrees](https://reader036.vdocuments.us/reader036/viewer/2022090606/605c5f017b1bf2425c664680/html5/thumbnails/13.jpg)
Motor sensorsEv3 Motors have inbuilt sensors to provide us with (fairly) accurate data on how to the motor is doing while driving. They can detect anything from speed to whether or not the motor is stalled.
STEMPowering Girlshttps://stempoweringgirls.org
![Page 14: EV3 Micropython Lesson 2 · EV3 Micropython Lesson 2 By STEMPowering Girls stempoweringgirls.org. Review Last week, we learned how to make the robot move forward and backwards, degrees](https://reader036.vdocuments.us/reader036/viewer/2022090606/605c5f017b1bf2425c664680/html5/thumbnails/14.jpg)
Motor AnglesThe angle of the motor is how many degrees it has travelled. Instead of resetting after each rotation it continues of grow (720 for 2 rotations, etc.). Its very useful in line following and gyro sensor programs.
To print out the current motor angle:
print(MotorB.angle())
To reset the angle:
MotorB.reset_angle()
STEMPowering Girlshttps://stempoweringgirls.org
![Page 15: EV3 Micropython Lesson 2 · EV3 Micropython Lesson 2 By STEMPowering Girls stempoweringgirls.org. Review Last week, we learned how to make the robot move forward and backwards, degrees](https://reader036.vdocuments.us/reader036/viewer/2022090606/605c5f017b1bf2425c664680/html5/thumbnails/15.jpg)
Motor Speed
The motor speed function returns the current speed of the motor that it has been called for.
print(MotorB.speed())
STEMPowering Girlshttps://stempoweringgirls.org
![Page 16: EV3 Micropython Lesson 2 · EV3 Micropython Lesson 2 By STEMPowering Girls stempoweringgirls.org. Review Last week, we learned how to make the robot move forward and backwards, degrees](https://reader036.vdocuments.us/reader036/viewer/2022090606/605c5f017b1bf2425c664680/html5/thumbnails/16.jpg)
Motor StallThe motor stall function checks whether a motor is stalled. When a motor is stalled, it cannot move at all. If the motor is stalled, it will return TRUE. If not, it will return FALSE. This function is not used very often.
print(motorB.stalled())
STEMPowering Girlshttps://stempoweringgirls.org
![Page 17: EV3 Micropython Lesson 2 · EV3 Micropython Lesson 2 By STEMPowering Girls stempoweringgirls.org. Review Last week, we learned how to make the robot move forward and backwards, degrees](https://reader036.vdocuments.us/reader036/viewer/2022090606/605c5f017b1bf2425c664680/html5/thumbnails/17.jpg)
NOW Try it Yourself!Make the Motor Travel at a speed of 300 for 1.5 Rotations, while printing the speed/Angle of both motors.(Hint: You’ll Probably need a while loop)
STEMPowering Girlshttps://stempoweringgirls.org
![Page 18: EV3 Micropython Lesson 2 · EV3 Micropython Lesson 2 By STEMPowering Girls stempoweringgirls.org. Review Last week, we learned how to make the robot move forward and backwards, degrees](https://reader036.vdocuments.us/reader036/viewer/2022090606/605c5f017b1bf2425c664680/html5/thumbnails/18.jpg)
Touch Sensor
STEMPowering Girlshttps://stempoweringgirls.org
![Page 19: EV3 Micropython Lesson 2 · EV3 Micropython Lesson 2 By STEMPowering Girls stempoweringgirls.org. Review Last week, we learned how to make the robot move forward and backwards, degrees](https://reader036.vdocuments.us/reader036/viewer/2022090606/605c5f017b1bf2425c664680/html5/thumbnails/19.jpg)
Touch SensorThe touch sensor is a sensor that can detect whether or not it has been pressed. It is useful for checking whether or not the robot has run into a wall or another object.
STEMPowering Girlshttps://stempoweringgirls.org
![Page 20: EV3 Micropython Lesson 2 · EV3 Micropython Lesson 2 By STEMPowering Girls stempoweringgirls.org. Review Last week, we learned how to make the robot move forward and backwards, degrees](https://reader036.vdocuments.us/reader036/viewer/2022090606/605c5f017b1bf2425c664680/html5/thumbnails/20.jpg)
Touch Sensor
The pressed() function checks whether or not the touch sensor is being pushed down. If it is, it returns TRUE. If not, it returns FALSE.
print(touch.pressed())
STEMPowering Girlshttps://stempoweringgirls.org
![Page 21: EV3 Micropython Lesson 2 · EV3 Micropython Lesson 2 By STEMPowering Girls stempoweringgirls.org. Review Last week, we learned how to make the robot move forward and backwards, degrees](https://reader036.vdocuments.us/reader036/viewer/2022090606/605c5f017b1bf2425c664680/html5/thumbnails/21.jpg)
NOW Try it Yourself!Create a program that makes the robot go forward until it runs into an obstacle (HINT: Use the touch sensor, not Motor Stall and don’t go to fast)
STEMPowering Girlshttps://stempoweringgirls.org