Introduction: Bull Zone
This instructable was created in fulfillment of the project requirement of the Makecourse at the University of South Florida (www.makecourse.com)
What does it do?
This project is a fun and simple model of a robotic bull that will execute a set of predefined responses depending on how close an object is to its position. The proximity of the object will be determined by a proximity sensor.
There are three different proximity zones, where each zone causes a different reaction from the bull. In the outer zone, there is no response. In the middle zone, two red LEDs are illuminated indicating that the bull is slightly agitated. In the inner zone, the bull will rotate its leg in a pawing motion as if it is preparing for a charging attack. The bull; however, does not charge towards the object. Below is the control system block diagram for the project:
Step 1: Control System Diagram
Step 2: Preparation
- 1x Arduino Uno micro controller
- 1x Standard Sized Servos
- 1x HC-SR04 Ultrasonic Sensor
- 1x Breadboard
- 20x Jumper Cables
- 1x Electrical Tape
- 2x Red LEDs
- 1x 9V Battery
- 1x 9V Power adapter
- 1x Hardboard Tempered Plywood
- 1x Gorilla Wood Glue
- 1x Spool of Solder Wire
Access to laser cutter, 3D printer, and solder iron
Step 3: 3D Printing/ Laser Cutting & Assembly
All of the parts were designed in Autodesk Inventor Professional 2018. The .stl files were exported from Autodesk Inventor and included in this step for reference. The 3D parts were printed with the FlashForge Finder 3D printer by uploading the .stl to the printer's build setting via the FlashPrint software. The material used for the filament was PLA. The infill setting that was used for each print were 15% fill density with a hexagon fill pattern. Feel free to visit http://www.flashforge.com to obtain more information on how to use the 3d printer and the FlashPrint software.
The laser cutter was used for the design of the enclosure and the two profile of the bulls. Two holes were made on the front side of the enclosure for the HC-SR04 Ultrasonic Sensor, and a small rectangular hole on one the sides which would allow for a tight fit once the servo motor is inserted. A rectangular hole was also made on the front side so that the bull's head could easily be inserted.
Once all the parts has been made, assemble the enclosure with wood glue and insert the servo motor into the rectangular hole on the side of the enclosure, and the insert the head of the bull on the rectangular hole in the front profile of the enclosure. The bull's back will also be glued to the top side of the enclosure.
Step 4: Wiring
Wiring the parts to the breadboard and Arduino is the final step in the assembly process. Refer to the Fritzing diagram for a detailed schematic of the wiring. When connecting the red LEDs, make sure that a 220 ohm resistor is connected in series.
Solder two jumper wires to the positive and negative terminals of each LEDs. Use an electrical tape to insulate any exposed metal. All that is left is to upload the code which will be discussed in the next step.
Step 5: Code
Servo.h is the free standard servo library for Arduino that was used in the Arduino sketch. The Servo.h library allow for the user to interface the Arduino to control the servo motor. Servos have integrated gears and a shaft that can be precisely controlled. Using the functions associated with the library will allow for the user to position the motor at various angles.
The HC-SR04 library will allow for the user to use an HCSR04 Ultrasonic Proximity Sensor to determine if an object is approaching or retracting.
I have included the Arduino sketch with detailed commentary to aid with the coding process.
The sketch begins with a list of a pre-processor directive that includes the library for the proximity sensor and the servo motor, and a list of definition to be referred in the sketch for simplicity. These include the echo pin and trigger pin of the proximity sensor, the servo pin of the motor, and the two LEDs.
Next, I begin with the setup by instantiating both the sensor and the proximity sensor by calling the constructor of each element, which is included in the library. The LEDs are then configured by using the pinmode function to indicate that the associated pins will serve as outputs, and by using the digitalwrite function to ensure that the LEDs are off.
The main loop is what allows the bull to execute the predefined responses based on the proximity of the object. The Serial.Print functions are only used for debugging purposes. The distance variable is used to store the value that is continuously sent from the proximity sensor to the arduino. This variable is what determines which while loop is entered. There are two main while loops. The first loop is entered when the distance variable is less than 50 cm and greater than 20cm. In this case the led turns on. The Next loop is entered when the variable is less than 20cm. In this case the LEDs will turn on and the motor will rotate.
We have a be nice policy.
Please be positive and constructive.