EV3 Race Car
- Students will build a controllable robotic car.
- Students will use Python to program the car movement.
- 1 ultrasonic sensor
- 2 touch sensor
- 1 color sensor
- 2 large motors
- 1 medium motor
- EV3 brick with Wifi dongle and SD card (you should have access to the EV3 IDE
- Any other LEGO parts you need to build the car
Let's Get Started!
Note: This requires a lot of parts!
Click on the link above and follow the detailed instructions to build the race car.
Once the hot rod racer is complete, we can begin programming how to make it move. In this particular example, the movement is controlled via an activation key and 2 touch sensors that move the car left and right. The activation key is is composed of an orange colored lego brick and a color sensor. If the color sensor is reading the orange brick the car moves, if not then it stops. This allows for easy stop and play functionality.
First, define all sensors and motors. Then program the EV3 to move forward while the color sensor is reading the orange brick. In the same while loop program the EV3 to move left if one of the touch sensors is pressed and right for the other. Explore the snippets on the right side of the IDE to come up with this code.
Given below is an example program. When touch sensor 1 is pressed motor A rotates clockwise, when touch sensor 2 is pressed motor A rotates counter clockwise! Try changing which touch sensor makes the car go left and which one make the car go right!
Here is a cool video of how the car works using the code above.