EFA | The Little EFA Robot V2


Code for testing the motors

You can download the starting point for the code:

Use this code to test that the motors and the H-Bridge work correctly before moving on to the sensors. I created another tab for the motor functions. This is just to keep things organized.

You can add a new tab with the arrow icon. I named the file motorfunctions

Final Code

This is the final code for our robot. It does the following things:

  • A light sensor reads the light level
  • The distance sensor reads the distance to objects in front of it
  • The light level is mapped to the speed of the motors. The darker it is, the slower the robot moves.
  • If the distance sensor detects something in front of it closer than 500mm, the robot turns left, otherwise it keeps on moving forward.