Introduction: Arduino Uno T-Rex Battery Tester

Picture of Arduino Uno T-Rex Battery Tester

This instructable was created in fulfillment of the project requirement of the Makecourse at the University of South Florida (www.makecourse.com)

Hello and welcome to my Arduino Uno T-Rex Battery Tester project. This project includes both the STL files and STEP files so printing the parts in this project can be a breeze, along with the freedom of tweaking my design to your personal liking.

Also make sure to watch the initial overview as I detail the entire process from how parts are connected, how they work together, and how my code works to produce the final result at the end.

Step 1: Gather the Necessary Components!

Picture of Gather the Necessary Components!

Below is a list of the necessary components and Amazon/Adafruit/eBay links to purchase from. Unless you plan on making a bunch of these battery testers, I recommend going to a local electronics store if you have one, so you can save by not having to buy components in bulk.

TIP 122G or 2N3055 Transistor:

http://smile.amazon.com/Through-Hole-Epitaxial-Tra...

Arduino SD Module:

http://smile.amazon.com/Card-Module-Socket-Reader-...

2x Common Cathode RGB LEDs:

http://smile.amazon.com/Round-Common-Cathode-Emitt...

1x Standard LED:

https://www.adafruit.com/products/299

1x Photocell:

https://www.adafruit.com/product/161

2x SG90 Mini Servo Motors:

http://smile.amazon.com/TowerPro-SG90-Micro-Servo-...

1x 8 ohm Speaker:

https://www.adafruit.com/products/1313

1x 9V Battery if Arduino is USB powered and 2x if powering Arduino through power jack:

http://smile.amazon.com/Duracell-Alkaline-Batterie...

Resistors needed are listed below (Note that written numbers indicate how many resistors are needed for actual project, bulk amounts should be plenty enough for the project.):

Two 10 ohm Resistors (Brown-Black-Black):

http://smile.amazon.com/E-Projects-Ohm-Resistors-W...

Three 1k Resistors (Brown-Black-Red):

http://smile.amazon.com/E-Projects-Ohm-Resistors-W...

Three 10k Resistors (Brown-Black-Orange):

https://www.adafruit.com/products/2784

Two 1.2K Resistor (Brown-Red-Red):

http://smile.amazon.com/Resistors-1-2K-250V-Carbon...

One 12K Resistor (Brown-Red-Orange):

http://smile.amazon.com/E-Projects-12k-Resistors-W...

One 220 ohm resistor (Red-Red-Brown):

https://www.adafruit.com/products/2780

Capacitors needed are listed below:

One 10,000 uF Capacitor:

http://www.ebay.com/itm/2-x-6-3V-10-000uf-Radial-E...

Four 100uF Capacitors:

(Ignore the component chart above on this one as you actually need 4 100 uF capacitors. Just hook up your 4 100uF capacitors in series to get the 25uF needed)

http://smile.amazon.com/100uF-105C-Radial-Electrol...

One 3904 Transistor:

http://smile.amazon.com/uxcell-2N3904-Through-Thre...

Also if you don't have any hookup wires, here is a spool of 20 gauge wire to use with your breadboard:

http://smile.amazon.com/Frey-Scientific-581181-Con...

Wire cutter/stripper:

http://smile.amazon.com/Hakko-CSP-30-1-Stripper-Ma...

Soldering iron:

http://smile.amazon.com/J-L-SI60-Watt-Soldering/dp...

60/40 Rosin Core Solder:

http://smile.amazon.com/Alpha-AM31406-Cookson-Elec...

This should be everything needed to assemble the project.

Step 2: Solder Wires to Both RGB Led Pins, Standard Led, Contact Pads, and Photocell

Picture of Solder Wires to Both RGB Led Pins, Standard Led, Contact Pads, and Photocell

As stated in the title, you need to solder wires to both pins on the standard red LED, both pins on the Photocell, the Red, Green, and Common pins on the RGB LEDs as shown above, and to metal contact pads (Preferably Copper or Aluminum. I suggest cutting out strips of Aluminum from soda cans and using sandpaper to scratch off outer label and inner plastic coating for the pieces used).

Step 3: Connect All of Your Components to Your Board As Shown in the Fritzing Diagram.

Picture of Connect All of Your Components to Your Board As Shown in the Fritzing Diagram.

Attached are my Fritzing files below to see how I connected all of the components to my breadboard. Check the first image above to connect the optional audio amp circuit if want a louder T-Rex roar. If you don't have Fritzing, click the link below for a free download:

http://fritzing.org/download/



Step 4: Upload the Code to Your Arduino Using the Arduino IDE Program

Picture of Upload the Code to Your Arduino Using the Arduino IDE Program

Use the code pasted below, or better yet, use the attached Arduino sketch to send the code to your Arduino.

Make sure to watch this embedded YouTube video, as I explain how all the code works in making what you physically see in both the final video and in the Fritzing breadboard sketch.

// Polygonasaurus Rex Battery Tester
// Created by Daniel Rudzik // This code is Public Domain. Feel free to use it as you please! =)

#include //This is the standard servo library #include // need to include the SD library //const int chipSelect = 4; #define chipSelect 4 //using digital pin 4 on arduino nano 328, can use other pins #include // also need to include this library... #include

TMRpcm tmrpcm; // create an object for use in this sketch (new code) Servo servo1; // create servo object to control a servo Servo servo2; // create servo object to control a servo // twelve servo objects can be created on most boards int pos = 90; // variable to store the servo position int sensorPin = A0; // select the input pin for the potentiometer int ledPin = 13; // select the pin for the LED int sensorValue = 0; // variable to store the value coming from the sensor int BatteryPin = A5; // select the input pin for the potentiometer int BatteryValue = 0; // variable to store the value coming from the sensor unsigned long time = 0; //Used to help store number value

void setup() { digitalWrite(3, LOW); //Displays red light from the RGB Led digitalWrite(2, HIGH); // Keeps the RGB green light off servo1.attach(8); // attaches the servo on pin 8 to the servo object servo2.attach(7); // attaches the servo on pin 7 to the servo object pinMode(BatteryPin, OUTPUT); pinMode(2, OUTPUT); //green is digital pin 2 pinMode(3, OUTPUT); //red is digital pin 3 Serial.begin(9600); //Allows values to be displayed in serial monitor pinMode(9, OUTPUT); tmrpcm.speakerPin = 9; //5,6,11 or 46 on Mega, 9 on Uno, Nano, etc Serial.print("Initializing SD card..."); // make sure that the default chip select pin is set to // output, even if you don't use it: pinMode(10, OUTPUT); // see if the card is present and can be initialized: if (!SD.begin(chipSelect)) { Serial.println("Card failed, or not present"); // don't do anything more: return; } Serial.println("card initialized."); }

void loop() { BatteryValue = analogRead(BatteryPin); // read the value from the AA battery Serial.println(sensorValue); //Displays the Photocell sensor values in Serial Monitor change 'sensorValue' to 'BatteryValue' when testing battery instead of light readout from photocell. if (BatteryValue>100){ // Value is greater than 100 when the AA is connected and has power left in it. Should work fine with your AA batery but if not, change the value from 100 to what comes up in serial monitor when the battery makes contact. tmrpcm.play("a.wav"); // Plays the T-Rex Roar when the value is greater than 100 and the SD card is ok. digitalWrite(2, LOW); //Turns off the Red light from the RGB led digitalWrite(3, HIGH); // Turns on the Green light from the RGB led } else{digitalWrite(3, LOW); // Turns on the Green light from the RGB led digitalWrite(2, HIGH);} //Turns on the Red light from the RGB led sensorValue = analogRead(sensorPin); //Detects the value on the Photocell to determine whether it is blocked from the light if (sensorValue>700){ // When the Photocell value is greater than 700, it is being blocked for(pos = 90; pos >= 19; pos --){ //Goes from 90 down to 19 degrees. servo1.write(pos); servo2.write(180-pos); //Simultaneously mirrors the other servo motor to move t-rex skull down } delay(1000); for(pos = 19; pos <= 90; pos ++) // Goes from 19 degrees to 90 degrees { servo1.write(pos); // tell servo to go to position in variable 'pos' servo2.write(180-pos); // tell servo to go to position in variable 'pos' delay(15); // waits 15ms for the servo to reach the position } } }

Step 5: 3D Print the Parts!

Picture of 3D Print the Parts!

Below is a link to my Thingverse page for the T-Rex Battery Tester where you can find both the STL files, as well as the STEP files to tweak the design however you desire. I suggest going over the servo mount bracket edges with sandpaper so you can get a tight fit for your servos. Also, I suggest using Loctite plastic epoxy or Loctite 401 to stick the servo horns to the T-Rex skull as seen in the main picture.

Thingverse:

http://www.thingiverse.com/thing:1190669/#files

Step 6: Final Step. Finish It Up!

Picture of Final Step. Finish It Up!

Now your almost done. All you have to do now is to push the LEDs through the eye sockets on the T-Rex skull, put metal contacts into skull and jaw of the model. You can also use poster adhesives or some other type of adhesive to stick half-size breadboards on the inner walls of the T-Rex jaw box, as well as your speaker and and Arduino Uno. The servo stands should fit fine into the sockets on the T-Rex Jaw base, but I recommend using poster adhesive strips to connect the stands to the base as well to give a little extra distance and ensure a tighter hold.

Also attached is the T-Rex roar sound clip that you will want to just put in the root section of your SD card.

Everything should work fine if you followed all of the steps correctly. If you need help or have any other questions, feel free to let me know in the comments!

Comments

tomatoskins (author)2015-12-10

Hahaha so cool! I love the addition of the sound!

drud1995 (author)tomatoskins2015-12-10

Thanks!

About This Instructable

350views

3favorites

More by drud1995:Arduino Uno T-Rex Battery Tester
Add instructable to: