The LittleBot Budget is made with an ultrasonic sensor for eyes. These "eyes" send out pings of sound waves that humans can't hear that bounce off of object and come back to the robot. Based on the time of the waves to leave the eyes and return the robot can measure its distance from an object and students can program a reaction for the robot to have.
Here we will walk through how to activate and read distance from the ultrasonic sensor on the Littlebot Budget robotics kit.
How to Activate the Ultrasonic Sensor on the LittleBot Budget
In order to activate and read the ultrasonic sensor on the LittleBot Budget all you have to do is use the ultraSensor() function that is provided in the LittleBot Budget code.
The ultraSensor function needs only two inputs the trigger pin of the sensor and the echo or reciever pin. On the LittleBot Budget both of these are already defined and ready to use so all you have to do is enter the function:
Calling that function will return the distance the sensor reads in CM, which can then in put into a variable by setting the function equal to a variable.
A simple example is attached below.
In this code sample, all students have to do is upload the code to the LittleBots Budget or add in the ultraSensor function on their own with any other code they want.
When the code is uploaded students can open the serial monitor (seen on the right below) in the Arduino Software to read the distance that the sensor is reading. (This distance is in Centimeters)
Projects for the Students with the Arduino Ultrasonic Sensor