# SunFounder DIY 4-DOF Sloth Robot Kit

Today we will have a look at a robot kit created by SunFounder. The Sloth is a bi-pedal robot based on the Arduino Nano. It utilises an ultrasonic module for obstacle detection and four servos for movement.

I found the kit to be an easy and fun build that took approximately an hour to complete. SunFounder have uploaded a YouTube video that serves as detailed introductions and assembly tutorial for the robot. It covers the entire assembly process, including the process to test the ultrasonic module as well as all the servos (before assembly), which is a good thing as one of the servos included with my kit turned out to be broken, but luckily I had a replacement servo on hand.

One thing to note is that the robot utilises two 18650 batteries, which after some research turned out to be commonly used in high-end flashlights and e-cigarettes, and are relatively pricey.

The robot can also be powered through the mini USB port on the Arduino (which I did while I waited for the batteries I had ordered to be delivered).

The code for the robot can be downloaded from here on the SunFounder website. Just note that the default code did not work for me as the ultrasound module did not detect obstacles. I rectified this by replacing the following code:

```void loop()
{
int <span class="mceItemHidden" data-mce-bogus="1"><span class="hiddenSpellError" pre="int " data-mce-bogus="1">tooclose</span></span> = 0; // Define the test times, the initial value is 0
for(int a=0; a&lt;5; a++)  //for is a cyclical function and its cyclic times are determined by the second condition in the bracket. Here a&lt;5, a’s initial value is 0. When a&lt;5, run the program in the bracket. After running, a becomes a++ and it means adding 1 to a’s value.
{
delay(50); // Delay 50ms
int din = sonar.ping_in(); // Call the ultrasonic transducer to read the distance that ultrasonic detected.
if (din &lt; 7 &amp;&amp; din &gt; 0) tooclose++; // The smoothing. The times add 1 when the detect distance less than 7cm and greater than 0cm.
}
```

With this:

```void loop()
{
int <span class="mceItemHidden" data-mce-bogus="1"><span class="hiddenSpellError" pre="int " data-mce-bogus="1">tooclose</span></span> = 0; // Define the test times, the initial value is 0
for(int a=0; a&lt;5; a++)  //for is a cyclical function and its cyclic times are determined by the second condition in the bracket. Here a&lt;5, a’s initial value is 0. When a&lt;5, run the program in the bracket. After running, a becomes a++ and it means adding 1 to a’s value.
{
delay(50); // Delay 50ms
int din = sonar.ping(); // Call the ultrasonic transducer to read the distance that ultrasonic detected.
if (din &lt; 750 &amp;&amp; din &gt; 0) tooclose++;
}
```

I really enjoyed assembling and playing with this little robot and would definitely recommend it to anyone interested in getting started in basic robotics.