Useless Button Bot

by anzu_k_2010 in Circuits > Arduino

338 Views, 1 Favorites, 0 Comments

Useless Button Bot

Scanned+Documents+21.jpg

This useless robot is the take on the ‘useless box’, a box with a switch and once the user flips the switch, the robot immediately switches it back to the original position. This robot, however, is a box with not just 1 but 2 buttons on it. As the user presses the left button, the robot does, absolutely nothing. As the right button is presses, the robot will repeat the button presses back at you. A simple, input, output, repeat robot.

Supplies

Hardware things you will need:

Pushbutton (2)

Mini breadboard

10 k ohm Resistor (2)

Servo motor

5 V battery

Arduino UNO board

Arduino Code

Screen Shot 2022-03-09 at 3.42.06 PM.png

This is where we get every variable, and where we connected it in the Arduino UNO board. We create the startTime and endTime variable, so later we can calculate the duration. We make a timerRunning variable, to use in out declaring statement in the loops portion. Import the Servo library so we can use it later. The ‘pos’ variable is how much, in degrees, we want to move the servo motor, so we can hit the button.

An array in Arduino

An array in Arduino is similar to a list of numbers, except elements can be referenced by the index number. We declate an array using the box brackets ‘ [ ] ‘ . Set the array maximum however many inputs button presses you would want. In this case, I chose 10 as 10 buttons pressed seemed to enough button presses, I wanted. Setting up

Setting Up

Screen Shot 2022-03-09 at 3.42.14 PM.png

When setting up, put in the code the buttons as in input setting, although the output button is called ‘output’, we need the input of the button press. Next we set up the array in which we will store information of the input button presses with the next line ‘ for(int n = 0 <10;n++) sequence [n] = 0; In the next loop we will add elements to this array according to the duration of the button press. The last line of the ‘theServo.write(0);’ function sets the servo motor at the starting position of 0. Serial begin: This function is the operations that sets up the communication between the serial monitors. It is the speed in which the data is given to the serial monitor. In this case we set it as 9600, meaning that 9600 bits of data will pass through each second.

Figuring Out the Loops

Screen Shot 2022-03-09 at 3.42.30 PM.png

This is the if loop of the first input button press. Once the input is received the timer using ‘millis’ function is used. Stop the timer and then calculate the duration by setting ‘duration = endTime – startTime;’. After this is set the button press number should be recorded and so we add to the record counter in the next line. Next, we put that information in the sequence array, but we subtract 1 because the first value is 0.
The 'Millis' function is used because it returns the time in milliseconds back to the Arduino board. Where as the delay function would just stop the arduino before running for the period in which the user sets it as.

In the last loop, is when the output button is pressed. Once this happens the Servo motor will move on the position variable, we set it as in the initializing part of the code. In this case the servo will move 120 degrees, or the point where it will touch the button. After motion, the servo will stay in that position until the end of the timer from the first element in the sequence array. This is done by ‘delay (sequence [i]);’. Once that is done the index and the duration will be printed on the serial monitor.

Hardware Circuit

Screen Shot 2022-03-09 at 4.52.03 PM.png

Using the mini board, first place the push buttons in the middle portion and connect them to the 5V output of the Arduino board to get the current flowing. Using the 10 k resistor connect it to the other side of the button and then to the ground. As for the servo motor connect the signal, power and ground.

Connection to the Arduino

Input Button: ~3

Output Button: ~ 5

Servo Button: ~9

Wiring of the Circuit

Screen Shot 2022-03-09 at 5.00.01 PM.png

This is the logic of the circuit. We will use a parallel circuit with 2 push buttons and a servo motor.

Making the Box

uselessrobot.jpg
uselessbot(diagram).jpg
Screen Shot 2022-03-10 at 1.54.29 PM.png

Out of plexi make:

Rectangle

60 mm x 80 mm (2)

57mm x 80 mm (2)

38 x 60 mm with a 10mm x 3 mm rectangle cut out

Plexi Glass

Using a laser cutter, cut out the parts from a plexi glass. Follow you laser cutting instructions and adjust the speed, and power of the laser accordingly.

The rhino file will is attached to the instructable

- Using an acrylic adhesive, connect and glue the rectangles accordingly
- Place the top rectangle with the cut out on top, and glue down

o The servo motor will fit in this cut out

- Place the Breadboard, Servo Motor, Battery, and Arduino UNO board according to the diagram below

Making the Hardware

IMG_2387.png
IMG_2388.png

After cutting out the pieces from the laser cutter, glue the parts according to the diagram. The 60 mm x 80 mm rectangle placed in the front and the 57mm x 80 mm rectangle on the side. Next glue to top piece, and place the ardunino and battery in the box. The servo motor should fit in the rectangle cut-out.

upload the code, connect the battery and enjoy your new copy cat useless bot.

Here Is a Video of the Bot in Action!

Download the Files

Reflection

Scanned Documents 22.jpg
Scanned Documents 222.jpg

During this process of creating the useless bot, figuring out the pseudocode was the hardest. Because the purpose was simple, it was important for me to understand the code. It was my first time working with the millis() function, and understanding the difference between it and delay() was the most difficult. Also the syntax with arrays, and figuring out the output was by far the most challenging. Looking at online codes and forums were helpful. Looking at other people with a similar problem was also encouraging. Overall, the most time consuming process was debugging the code, remembering the semicolon. Also, knowing the difference between '=' and '==' for '=' sets the variable, and '==' checks to see is the two values match.

I must say though, though help from my class, when the code worked after working on it for an a ridiculous amount of time, when it finally worked it was worth it.

Within this project I also was able to use the laser cutter, something i hadn't used in a long time. It was nice to brush up on these skills again, for it would be a useful skill for future projects.