Introduction: Graphite Dispenser

This instructable was created in fulfillment of the project requirement of the Makecourse at the University of South Florida (

Within this instructable you will be able to create a graphite dispenser for your desk, which allows you to refill an empty mechanical pencil quickly. All that's required are some fairly basic materials, other than access to a 3D printer.

Step 1: Tools and Materials


  • 3D printer
  • Hot glue gun
  • Scissors


  • 1x Arduino UNO board
  • 1x C-47P DC Series Heavy Duty Electronics Enclosure
  • 2x SG90 9G servos
  • 1x 3-Pronged IR receiver
  • 1x IR Controller/Remote (Make sure to include batteries)
  • 1x HC-SR04 Proximity Sensor
  • 1x Mini Breadboard with Power Rails
  • 1x 5V USB Portable Phone Charger (Preferably Small) + USB Cord


  • Cardboard
  • Rubberbands
  • Tape

Step 2: Setting Up the Wiring

Above are the Fritzing diagram, block diagram, and the physical wiring that was used. Note that a mini breadboard was used, and the yellow and orange colored wires are switched (color-wise) compared to the physical model.


  1. Connect the 5V and GND pins on the Arduino to the power rail on the breadboard.
  2. Wire Servo 1 to Digital Pin 7. Connect to Power Rail.
  3. Wire Servo 2 to Digital Pin 3. Connect to Power Rail.
  4. For the Proximity Sensor Connect the Trig Pin to (Orange on Fritz/Yellow in the Physical) Digital Pin 1. Connect the Echo Pin to Digital Pin 4 (Blue Wire on both Fritz and Physical) Connect to Power Rail.
  5. Connect the Signal Pin of the IR Sensor (Yellow in Fritz, Orange in the Physical) to Digital Pin 6. Connect to Power Rail.

Step 3: Preparing the 3D Printed Parts

Included within the attached ZIP file

  1. Main Cover (The body of the graphite dispenser. Attaches to the electronics enclosure. Depending on your 3D printer this may need to be printed in two separate parts. Your printing program should allow for cutting models.)
  2. Tubes (Three long tubes that attaches to Servo2 to switch graphite thicknesses.)
  3. Better Disc Thing (A small disc that attaches to Servo2 which prevents the graphite from falling into the Graphite Dispenser)
  4. Better Stopper Thing (Attaches to Servo1 and prevents graphite from falling out of the dispenser too early.)
  5. Small Sliding Cover (A small cover that slides into the Main Cover to hid the insides. May require to be filed to fit into the slot in the Main Cover depending on print.)

Included are .STL and .OBJ files, which are both compatible for printing. When adding supports, keep in mind that some of the components are small, which would cause removing the supports to be difficult.

If you are more comfortable not downloading a ZIP file, the individual parts are also attached.

Step 4: Coding the Graphite Dispenser

Attached is a ZIP file containing all the code needed to run the Graphite Dispenser. Included is the .INO file, the .CPP file, and the .H file. Also attached are the libraries used, which are the Servo library and the IRremote library. Credit goes to the original creators of said libraries.

Furthermore, the video attached describes what each piece of the code does. A quick description of the code is found below:

The Header and CPP files control the proximity sensor. The sketch is sectioned off into individual portions that describe their function. (e.g. //IR Sensor and Servo// section describes the various integers and pre-setup code that runs the IR Sensor and Servos.)

Upload this into the Arduino UNO.

Step 5: Assembly

Connecting the Arduino Parts to the 3D Printed Parts

  1. Disconnect the Power Rail from the breadboard. You may use the adhesive on the back of it, however it may not stick to the plastic, so hot glue was used. Glue both the Rail and the Breadboard to the back of the Main Cover similar to how it is set up in the picture.
  2. By doing step one, the IR sensor and the proximity sensor should line up with the holes within the Main Cover. Fasten both to the Cover.
  3. For attaching the Disc to Servo2, make sure that is tall enough to reach the bottoms of the tubes, but with enough space so that they aren't touching. In this case, the Servo was slightly different compared to the 3D model used, so the hole needed to be enlarged to fit this Servo and cardboard was used to prop it up higher.
  4. Attached the Tubes to the top of the Servo, to the portion that rotates. Makes sure the middle tube is above the cone.
  5. Attach the Stopper to Servo 1, make sure that it first under the middle tube, is above the cone, and is leveled with the disc.
  6. With steps 4 and 5 finished, glue the servos to the plastic, making sure everything lines up.
  7. In relation to the Rechargeable Phone Battery, refer to the picture above. The Arduino chord is spooled and held together using rubber bands, then attached to the battery pack. The USB used for charging the pack is also attached.
  8. Refer to the first picture for the final locations of the pieces; as when you close the cover everything should fit nicely.
  9. Fasten the Main Cover to the Electronics Enclosure using hot glue.

Step 6: Usage

To use it, place the top part of the pencil into the cone portion of the Graphite Dispenser. The Proximity Sensor should detect the pencil/hand and dispense the graphite into your pencil. If you would like to switch graphite types (thickness) use the remote and press buttons 1, 2, or 3 (or whatever you decided to change the buttons to for your desired graphite type).