The RedBot is a small, pre-built two motor robot that introduces robotics and sensors integreation. The RedBot is coded and operated with Arduino microprocessors and the Arduino programming language.
As stated before, the RedBot is coded and operated using the Arduino programming language. To write and upload Arduino code, we have to use the Arduino IDE (integrated development environment).
Above is an example of Arduino code. The Arduino programming language, and the Arduino IDE itself, is derived from C++. This similarity can be seen in the syntax, mainly with the method structure and the use of semi-colons.
To code the RedBot, we needed to use the SparkFun library, which includes commands specific to using the RedBot.
Shown above are three functions that we wrote in order for the RedBot to be able to avoid obstacles. These functions were written using command from the Sparkfun library. For example, the turnRight() function uses three commands from the Sparkfun library, leftMotor(), rightMotor(), and stop(). The leftMotor() and rightMotor() functions allow us to control the motors individually, and provide a speed parameter for each. The stop() function allows the motors to coast and eventually, brings the robot to a stop. The delay() commands used are not part of the Sparkfun library, but rather, they are a built-in Arduino command. The command delay(1500) allows us to keep the motors running for 1.5 seconds.
The final challenge is to have the robot navigate the course shown below. For that, we had to code a line-tracking systems that used the color sensors on the bottom of the robot to track the black line and act accordingly.