Lesson 29 – Touch Sensing + Obstacle Detection with Dance Movement
What is OTTO DIY – Otto is completely open source, Arduino compatible, 3D printable robot which you can put together yourself. This is robotics and opensource at it’s best. The robot was designed by Camilloa Parra as a social impact mission to create an inclusive environment for all kids. Learn more about OTTO DIY and grab a kit at www.ottodiy.com.
Software Required : You will need either Otto Blockly or the Arduino IDE to work on this tutorial. Head over to the following page to learn how to get Otto Blockly or the Arduino IDE installed on your machine – https://learning.kidzcancode.com/lesson/lesson-03-programming-your-otto-robot/ . Once you have the tools installed, launch the relevant application i.e. Otto Blockly or the Arduino IDE and get started using the code shown below.
Uploading code to the Otto DIY Robot : To upload the code to the Arduino Nano (brain of your Otto DIY Biped Robot) you will need to make sure you have the Otto DIY robot connected to your laptop/desktop using the correct cable. Then select the right COM (Communication Port) and type of Arduino board using the drop down menus provided at the top of the screen. Once that’s sorted hit the “tick mark” icon to validate your code and make sure you do not see any errors pop-up. Finally hit the “right arrow” icon to have the code uploaded to the Arduino Nano housed within the Otto DIY robot.
Tutorial : As part of this tutorial you will load the relevant Otto libraries, initialize all the servos, add to the basics of movement and learn to make the Otto DIY Biped Robot dance. You will trigger the dancing sequence when the Arduino Capacitive Sensor (connected to analog pin A0) is touched, but also check for presence of objects in front of you before you make the decision to commence walking.
As a challenge can you explore other movements techniques, add to the walking movements and possibly also introduce dancing techniques and see what your Otto DIY Biped Robot is capable of.
See Otto Blockly code example below –


See Arduino code provided below.
#include <Otto.h> //Requires you to have the Otto libraries installed within the Arduino IDE
Otto Otto;
#include <Servo.h>
#include <PlayRtttl.hpp> //Make sure you have installed the Playrtttl Arduino Library
#define LeftLeg 2 // left leg pin, servo[0]
#define RightLeg 3 // right leg pin, servo[1]
#define LeftFoot 4 // left foot pin, servo[2]
#define RightFoot 5 // right foot pin, servo[3]
#define Buzzer 13 //buzzer pin
void setup() {
Otto.init(LeftLeg, RightLeg, LeftFoot, RightFoot, true, Buzzer);
Otto.home();
pinMode(8, OUTPUT);
pinMode(9, INPUT);
Serial.begin(9600);
}
long ultrasound_distance_simple() {
long duration, distance;
digitalWrite(8,LOW); // Setting TRIG pin LOW
delayMicroseconds(2);
digitalWrite(8, HIGH); // Setting TRIG pin HIGH for 10uS which causes the sensor to send out 8 pulses
delayMicroseconds(10);
digitalWrite(8, LOW); // Setting the TRIG pin LOW to disable
duration = pulseIn(9, HIGH); // Setting the ECHO pin high, measuring time duration for which a pulse was received
//distance = duration/58; // Measuring the distance OR
distance = duration * 0.017;
return distance;
}
void loop() {
if(digitalRead(A0)) { // Reading input from the touch sensor
Otto.home();
delay(1000);
Serial.print("Ultrasonic sensor reading:");
Serial.print(ultrasound_distance_simple());
Serial.print("cm");
Serial.println("");
if (ultrasound_distance_simple() >= 30) {
// Otto Walking Functions, Sounds, Gestures are here
// Read the following page to understand functions for various Otto walking movements, dance movements, Sounds, Gestures
// https://github.com/OttoDIY/OttoDIYLib
Otto.sing(S_superHappy);
for (int count=0 ; count<2 ; count++) {
Otto.walk(1,1000,1); // FORWARD
Otto.walk(1,1000,-1); // BACKWARD
}
for (int count=0 ; count<5 ; count++) {
Otto.moonwalker(1, 1000, 25, 1);
}
for (int count=0 ; count<5 ; count++) {
Otto.moonwalker(1, 1000, 25, -1);
}
for (int count=0 ; count<2 ; count++) {
Otto.swing(1, 1000, 25);
Otto.jitter(1, 1000, 25);
}
Otto.playGesture(OttoLove);
Otto.home();
delay (0.5*1000);
} else if (ultrasound_distance_simple() <= 10) {
Otto.sing(S_OhOoh);
Otto.walk(2, 1000, -1);
Otto.playGesture(OttoFart);
Otto.home();
}
}
}
Purchasing the OTTO DIY Robot : To learn more about the Otto DIY robot or purchase a off the shelf kit please head over to the OTTO DIY website at www.ottodiy.com. By purchasing the kit you will be supporting Camillo Parra and the rest of the OTTO DIY Robot team. At the OTTO DIY website www.ottodiy.com you also have the option to purchase the kit without the 3D printed parts, print the parts yourself using your own 3D printer at home.
For those interested in downloading the 3D models for printing using your own 3D printer, you will find a number of OTTO DIY robot re-mixes (3D print models) along with the original project at the Printables website (hosted by the guys who own Prusa). So head over to the 3D models hosted at Printables.com website to see all the different variants of the OTTO DIY robot listed there. If you are just wanting to download the parts for the basic Otto DIY Biped Robot then check out the following link at the main OTTO DIY Biped Robot page at the Prusa website.
For Makers, Creators & Innovators – If you are a maker, hacker and want to put together your own 3D printed robot using off the shelf components then check out this article at DIYODE – 2 Legged 3D Printed Robot. You can source all the components, parts listed above from Ebay/Amazon. If you do that, you are responsible for identifying and sourcing relevant parts, however if you purchase the kit from the OTTO DIY website www.ottodiy.com you will get quality parts including support from the OTTO DIY team.
Learn more about the OTTO Biped Project and join the OTTO DIY Robot community here – https://wikifactory.com/+OttoDIY/otto-diy and here https://wikifactory.com/+OttoDIY/otto-diy-plus
