Introduction: HackerBox 0040: PIC of Destiny

Greetings to HackerBox Hackers around the world. HackerBox 0040 has us experimenting with PIC Microcontrollers, breadboarding, LCD displays, GPS, and more. This Instructable contains information for getting started with HackerBox 0040, which can be purchased here while supplies last. If you would like to receive a HackerBox like this right in your mailbox each month, please subscribe at and join the revolution!

Topics and Learning Objectives for HackerBox 0040:

  • Develop embedded systems with PIC Microcontrollers
  • Explore in-circuit programming of embedded systems
  • Test power supply and clocking options for embedded systems
  • Interface a PIC Microcontroller to an LCD output module
  • Experiment with an integrated GPS receiver
  • Wield the PIC of Destiny

HackerBoxes is the monthly subscription box service for DIY electronics and computer technology. We are hobbyists, makers, and experimenters. We are the dreamers of dreams.


Step 1: Content List for HackerBox 0040

  • PIC Microcontroller PIC16F628 (DIP 18)
  • PIC Microcontroller PIC12F675 (DIP 8)
  • PICkit 3 In-Circuit Programmer and Debugger
  • ZIF Socket Programming Target for PICkit 3
  • USB Cable and Header Wires for PICkit 3
  • GPS Module with Onboard Antenna
  • 16x2 Alphanumeric LCD Module
  • Breadboard Power Supply with MicroUSB
  • 16.00MHz Crystals (HC-49)
  • Tactile Momentary Buttons
  • Diffused RED 5mm LEDs
  • 5K Ohm Trimmer Potentiometer
  • 18pF Ceramic Capacitors
  • 100nF Ceramic Capacitors
  • 1K Ohm 1/4W Resistors
  • 10K Ohm 1/4W Resistors
  • 830 Point (Large) Solderless Breadboard
  • Formed Jumper Wire Kit with 140 Pieces
  • Celluloid Guitar Picks
  • Exclusive PIC16C505 Die Decal

Some other things that will be helpful:

  • Soldering iron, solder, and basic soldering tools
  • Computer for running software tools

Most importantly, you will need a sense of adventure, hacker spirit, patience, and curiosity. Building and experimenting with electronics, while very rewarding, can be tricky, challenging, and even frustrating at times. The goal is progress, not perfection. When you persist and enjoy the adventure, a great deal of satisfaction can be derived from this hobby. Take each step slowly, mind the details, and don't be afraid to ask for help.

There is a wealth of information for current and prospective members in the HackerBoxes FAQ. Almost all of the non-technical support emails that we receive are already answered there, so we really appreciate your taking a few minutes to read the FAQ.

Step 2: PIC Microcontrollers

The PIC family of microcontrollers is made by Microchip Technology. The name PIC initially referred to Peripheral Interface Controller, but was later corrected to Programmable Intelligent Computer. The first parts in the family came out in 1976. By 2013, more than twelve billion individual PIC microcontrollers had been shipped. PIC devices are popular with both industrial developers and hobbyists due to their low cost, wide availability, large user base, extensive collection of application notes, availability of low cost or free development tools, serial programming, and re-programmable Flash-memory capability. (Wikipedia)

HackerBox 0040 includes two PIC Microcontrollers temporarily seated for transport in a ZIF (zero insertion force) socket. The first step it to remove the two PICs from the ZIF socket. Please do that now!

The two microcontrollers are a PIC16F628A (datasheet) in a DIP18 package and a PIC12F675 (datasheet) in a DIP 8 package.

The examples here use the PIC16F628A, however the PIC12F675 works similarly. We encourage you to try it out in a project of your own. Its tiny size makes for an efficient solution when you only need a small number of I/O pins.

Step 3: Programming PIC Microcontrollers With PICkit 3

There are a lot of configuration steps that need to be addressed when using the PIC tools, so here is a pretty basic example:
  • Install the MPLAB X IDE software from Microchip
  • At the end of the install, you will be presented with a link to install the MPLAB XC8 C Compiler. Be sure to select that. XC8 is the compiler we will be using.
  • Insert the PIC16F628A (DIP18) chip into the ZIF socket. Note the position and orientation listed on the reverse of the ZIF target PCB.
  • Set the jumper switches as indicated on the reverse of the ZIF target PCB (B, 2-3, 2-3).
  • Plug the five-pin programming header of the ZIF target board into the PICkit 3 header.
  • Connect the PICkit 3 to the computer using the red miniUSB cable.
  • Run the MPLAB X IDE.
  • Select the menu option to create a new project.
  • Configure: microchip embedded standalone project, and hit NEXT.
  • Select device: PIC16F628A, and hit NEXT
  • Select debugger: None; Hardware tools: PICkit 3; Compiler: XC8
  • Enter the project name: blink.
  • Right click source files, and under new select new main.c
  • Give the c file a name like "blink"
  • Navigate to window > tag memory view > config bits
  • Set the FOSC bit to INTOSCIO and everything else to OFF.
  • Hit the “generate source code” button.
  • Paste the generated code into your blink.c file above
  • Also paste this into the c file: #define _XTAL_FREQ 4000000
  • Past in the main block of c code below:
void main(void)
   TRISA = 0b00000000;
    while (1)
        PORTAbits.RA3 = 1;
        PORTAbits.RA3 = 0;

  • Hit the hammer icon to compile
  • Navigate to production > set project configuration > customize
  • Select PICkit 3 in left panel of the popup window and then Power from the dropdown field at the top.
  • Click the “power target” box, set the target voltage to 4.875V, hit Apply.
  • Back at the main screen, hit the green arrow icon.
  • A warning about about voltage will pop up. Hit continue.
  • You should eventually get “Programming/Verify Complete” in the status window.
  • If the programmer is not behaving, it can help to shut down the IDE and just run it again. All of your selected settings should be maintained.

Step 4: Breadboarding the PIC Programmed With Blink.c

Once the PIC is programmed (previous step), it can be dropped onto a solderless breadboard for testing.

Since the internal oscillator was selected, we only need to wire up three pins (power, ground, LED).

Power can be supplied to the breadboard using the power supply module. Pointers for using the power supply module:

  • Put some more solder on the side tabs of the microUSB socket before it breaks off - not after.
  • Make sure the "black pins" go into the ground rail, and the "white pins" into the power rail. If they are reversed, you are on the wrong end of the breadboard.
  • Flip both switches to 5V for the included PIC chips.

After positioning the PIC microcontroller, note the pin 1 indicator. The pins are numbered from pin 1 in a counter-clockwise fashion. Wire pin 5 (VSS) to GND, pin 14 (VDD) to 5V, and pin 2 (RA3) to the LED. Notice in your code, I/O pin RA3 is being cycled on and off to blink the LED. The longer pin of the LED should connect to the PIC, while the shorter pin should connect to a 1K resistor (brown, black, red). The opposite end of the resistor should connect to the GND rail. The resistor simply acts as a current limit so that the LED doesn't look like a short between 5V and GND and draw too much current.

Step 5: Programming In-Circuit

The PICkit 3 dongle can be used to program the PIC chip in-circuit. The dongle can also supply power the circuit (the breadboard target) just as we did with the ZIF target.

  • Remove the power supply from the breadboard.
  • Connect the PICkit 3 leads to breadboard at 5V, GND, MCLR, PGC, and PGD.
  • Change the delay numbers in the C code.
  • Recompile (hammer icon) and then Program the PIC.

Since the delay numbers were changed, the LED should blink differently now.

Step 6: Using an External Crystal Oscillator

For this PIC experiment, switch from the internal oscillator to a high-speed external crystal oscillator. Not only is the external crystal oscillator faster 16MHz instead of 4MHz), but it is much more accurate.

  • Change the FOSC configuration bit from INTOSCIO to HS.
  • Change both the FOSC IDE setting and the #define in the code.
  • Change #define _XTAL_FREQ 4000000 from 4000000 to 16000000.
  • Reprogram the PIC (maybe change the delay numbers again)
  • Verify operation with the external crystal.
  • What happens when you pull the crystal from the breadboard?

Step 7: Driving an LCD Output Module

The PIC16F628A can be used to drive output to a 16x2 Alphanumeric LCD Module (data) when wired up as shown here. The attached file picLCD.c gives a simple example program for writing text output to the LCD module.


Step 8: GPS Time and Location Receiver

This GPS module can determine time and location quite accurately from signals received from space into its small integrated antenna. Only three pins are required for basic operation.

The red "Power" LED will light up when proper power is connected. Once the satellite signals are acquired, the green "PPS" LED with start to pulse.

Power is supplied to the GND and VCC pins. The VCC can operate on 3.3V or 5V.

The third pin that is necessary is the TX pin. The TX pin outputs a serial stream that can be captured into a computer (via TTL-USB adapter) or into a microcontroller. There are numerous example projects for receiving GPS data into an Arduino.

This git repo includes pdf documentation for this type of GPS module. Also check out u-center.

This project and video demonstrates an example of capturing high accuracy date and time from a GPS module into a PIC16F628A microcontroller.

Step 9: Live the HackLife

We hope you have enjoyed this month's voyage into DIY electronics. Reach out and share your success in the comments below or on the HackerBoxes Facebook Group. Certainly let us know if you have any questions or need some help with anything.

Join the revolution. Live the HackLife. You can get a cool box of hackable electronics and computer tech projects delivered right to your mailbox each month. Just surf over to and subscribe to the monthly HackerBox service.