Otto Bot (I Named Mine Spike)
by gryffinmedina804 in Circuits > Robots
552 Views, 2 Favorites, 0 Comments
Otto Bot (I Named Mine Spike)
This is a simple project that just about anybody can do to create a simple walking robot.
Supplies
For this particular build you will need:
*Ultrasonic Sensor
*1 3d printed case
*4 servos
*Arduino nano board
*speaker
*9v battery pack
*9v battery
*8 female wires
* usb mini b cord
*portable battery
*decorations
*loaded hot glue gun
*soldering iron
*4 small screws
*screwdriver
*electrical tape
*4 small washers
Set Up/building
To start, you must first purchase the kit from: https://www.ottodiy.com/store/products/49452
Then follow the steps at: https://wikifactory.com/+OttoDIY/otto-diy
you may need to alter the casing to fir your parts so i used a soldering iron
Edits and Fixing Wires
While you do not have to decorate it adding to the otherwise bland casing and add extra dimensions to the bot just be sure to counter balance the weight so that the robot is balanced.
if you over strip your wires you can twist both sets together and seal them so that the current can pass through.
the 9v battery or even the 4 double a batteries may not be enough so I opted to just use a portable battery to plug into the board directly
I also added scotch tape to the bottom of my bot's feet for more traction
cable management will be tricky so I recommend using electrical tape to seal the sets of wires connecting to each other and placing the speaker and button towards the outside then seal to bot once everything is in place just enough so it will stay in place especially if the case is not entirely structurally sound
Upload Code
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------
// Otto_avoid sample sketch //-------------------------------------------------------------------------------------------------------------------------------------------------------------------- //-- Otto DIY PLUS APP Firmware version 9 (V9) //-- Otto DIY invests time and resources providing open source code and hardware, please support by purchasing kits from (https://www.ottodiy.com) //----------------------------------------------------------------- //-- If you wish to use this software under Open Source Licensing, you must contribute all your source code to the community and all text above must be included in any redistribution //-- in accordance with the GPL Version 2 when your application is distributed. See http://www.gnu.org/copyleft/gpl.html //--------------------------------------------------------------------------------------------------------------------------------------------------------------------- #include //-- Otto Library version 9 Otto9 Otto; //This is Otto!//--------------------------------------------------------- //-- First step: Configure the pins where the servos are attached /* --------------- | O O | |---------------| YR 3==> | | <== YL 2 --------------- || || || || RR 5==> ----- ------ <== RL 4 |----- ------| */ // SERVO PINs ////////////////////////////////////////////////////////////////////////////// #define PIN_YL 2 //servo[0] left leg #define PIN_YR 3 //servo[1] right leg #define PIN_RL 4 //servo[2] left foot #define PIN_RR 5 //servo[3] right foot // ULTRASONIC PINs ///////////////////////////////////////////////////////////////////////// #define PIN_Trigger 8 //TRIGGER pin (8) #define PIN_Echo 9 //ECHO pin (9) // BUZZER PIN ////////////////////////////////////////////////////////////////////////////// #define PIN_Buzzer 13 //BUZZER pin (13) // SERVO ASSEMBLY PIN ///////////////////////////////////////////////////////////////////// // to help assemble Otto's feet and legs - wire link between pin 7 and GND #define PIN_ASSEMBLY 7 //ASSEMBLY pin (7) LOW = assembly HIGH = normal operation /////////////////////////////////////////////////////////////////// //-- Global Variables -------------------------------------------// /////////////////////////////////////////////////////////////////// int distance; // variable to store distance read from ultrasonic range finder module bool obstacleDetected = false; // logic state for when object detected is at the distance we set /////////////////////////////////////////////////////////////////// //-- Setup ------------------------------------------------------// /////////////////////////////////////////////////////////////////// void setup() { Otto.init(PIN_YL, PIN_YR, PIN_RL, PIN_RR, true, A6, PIN_Buzzer, PIN_Trigger, PIN_Echo); //Set the servo pins and ultrasonic pins and Buzzer pin pinMode(PIN_ASSEMBLY,INPUT_PULLUP); // - Easy assembly pin - LOW is assembly Mode //Otto wake up! Otto.sing(S_connection);// Otto makes a sound Otto.home(); // Otto moves to its ready position delay(500); // wait for 500 milliseconds to allow Otto to stop // if Pin 7 is LOW then place OTTO's servos in home mode to enable easy assembly, // when you have finished assembling Otto, remove the link between pin 7 and GND while (digitalRead(PIN_ASSEMBLY) == LOW) { Otto.home();// Otto moves to its ready position Otto.sing(S_happy_short); // sing every 5 seconds so we know OTTO is still working delay(5000);// wait for 5 seconds }
} /////////////////////////////////////////////////////////////////// //-- Principal Loop ---------------------------------------------// /////////////////////////////////////////////////////////////////// void loop() { if (obstacleDetected) { // if there is an object closer than 15cm then we do the following Otto.sing(S_surprise); // sound a surprise Otto.jump(5, 500); // Otto jumps Otto.sing(S_cuddly); // sound a //Otto takes three steps back for (int i = 0; i < 3; i++) Otto.walk(1, 1300, -1); //repeat three times the walk back command delay(500);// small 1/2 second delay to allow Otto to settle //Otto turns left 3 steps for (int i = 0; i < 3; i++) { //repeat three times Otto.turn(1, 1000, 1); // the walk left command delay(500);// small 1/2 second delay to allow Otto to settle } } else { // if nothing in front then walk forward Otto.walk(1, 1000, 1); //Otto walk straight obstacleDetector(); // call the function to check the ultrasonic range finder for an object closer than 15cm } } /////////////////////////////////////////////////////////////////// //-- Functions --------------------------------------------------// //////////////////////////////////////////////////////////////////
/-- Function to read distance sensor & to actualize obstacleDetected variable void obstacleDetector() { int distance = Otto.getDistance(); // get the distance from the ultrasonic range finder if (distance < 15) obstacleDetected = true; // check to see if this distance is closer than 15cm, true if it is else obstacleDetected = false;// false if it is not
}
Librarys Needed
Once your libraries are extracted, you will need to go into Arduino IDE and make sure your bootloaders are up to date.
Set your board to Arduino Nano, your processor to ATmega328P (Old Bootloader), and your COM to whichever port you plugged your robot into. Once this step is done and your code is ready, press the upload button in the top left corner of the program to upload the code to your robot.
While you can find just about any code and library set not all of them will work witch can be supper frustrating.
Name, Enjoy, and Watch It Move
if all goes according to plan and the board is not fried you should have a bot that can be programs to sing, dance, move around and avoid obstacles.
While you could just call it Otto I find that naming it for yourself is a bit more interesting so I called mine Spike.