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 HackerBoxes.com 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 HackerBoxes.com and subscribe to the monthly HackerBox service.



    • Build a Tool Contest

      Build a Tool Contest
    • Organization Contest

      Organization Contest
    • Pocket Sized Contest

      Pocket Sized Contest

    28 Discussions


    4 days ago

    In order to display "Hacklife" you need to remove the ground from pin 10 of JP4 (D3) and instead tie it to +5v. Grounding puts the display in single line mode.


    6 days ago

    On step 6 - second bullet point [Change both the FOSC IDE setting and the #define in the code.] I'm lost on that one.


    Tip 12 days ago

    My system worked fine just as shown in the instructions, except that the "HackLife" Line was not generated on the LCD screen.

    Voltage set to 4.875 ( as it should be.... a little lower than max to program)

    Tip: Once you hit "generate source code", Paste the OUTPUT WINDOW at the bottom of the IDE into the source code (that wasn't all that clear in the instructions) then paste the _XTAL_FREQ 4000000 and the Blink code. Make sure you have #include too.

    Tip: Put the PIC into the ZIF starting on the SECOND ROW from the RIGHT so that there is one row between the end of the socket and pins 9 and 10 on the PIC. Pin One (the smallest dot on the top of the IC) should be pointed toward the lock-down handle on the ZIF.

    Tip: VSS = GND
    VDD = +5V (sometimes called Vcc)

    Tip: Build a 'tight' circuit (aka shortest wires possible even if you have to use more short jumpers to connect each pin to Vdd/Vss). Long wires make things tough to debug.

    Tip: Have the PICKit3 plugged into a true USB on your computer (not a dock or bus) and THEN open the IDE.

    Tip: Start a brand new project with for the LCD circuit. Start from the beginning of the instructions and follow the steps EXACTLY. Right Click the Source Files Folder and click "Add Existing Item" and then find the download of the picLCD.c source file and click ADD. Then set the Config bits again (use HS for the 16.000 Mhz Oscillator) and upload to the PIC.

    Tip: If you only See the green back light on the LCD or just Dark Blocks (After ensuring you've programmed the IC correctly) turn the blue trimm potentiometer with a small screwdriver or thin piece of plastic and the screen should show text. I believe it is CounterClockWise for dark blocks and ClockWise if you only see the backlight.

    1 reply

    Reply 8 days ago

    I had the same problem. I could get "HackerBoxes" but no "Hacklife" Played around with the code thinking the lcd_line2() function was an issue. Moving the cursor to space 40 is supposed to put it at the start of 2nd line but was the function moving it to space 40 or 40 spaces from where it was and thus off the right edge? Played around with different values but no joy. While playing around I turned up the contrast and noticed the dark pixels only showed on the 1st line. This made me think I had a bad LCD with a broke 2nd line. No problem, I've got others in my junk drawer. Pulled out a 4 line LCD, it has 2" wires connected to the 14 holes in the board. Did some googling and it should have the same HD44780 controller so I plugged the wires into the breadboard. Now there are 8 data wires, pins 7,8,9,10,11,12,13,14. In the schematic above 7-10 are connected to ground, only 11-14 are used and connected to the PIC. On my LCD from the junk drawer wires 7-10 were curled up from the others and obviously not connected so I left them floating. Applied power and I had "HackerBoxes Hacklife" both lines, success right? But wait! I unsoldered the wires and soldered in a strip of 16 pins. Plug it into the breadboard and now I'm back to only "HackerBoxes" Turn up the contrast and only lines 1 & 3 show pixels. Now the only thing different is pins 7-10 are not floating but grounded so I pulled the jumpers to those pins to leave them floating a viola! "HackerBoxed Hacklife"

    So, float pins 7-10 and you should see the Hacklife, now the question is, why? I want to say it has to do with whether it uses 4 line data input or all 8. Maybe they shouldn't be grounded but held high? Need to sleep, research later.

    15 days ago

    I am having the same problem. I changed it to 4.625 and I am getting the same output. Target device was not found (could not detect target voltage VDD). You must connect to a target device to use PICkit 3.

    5 replies

    Reply 11 days ago

    Don't forget to check off the "Power target circuit from PICkit 3" box when you set the voltage. That was tripping me up until I finally checked it off. After that I was good to go.


    Reply 11 days ago

    Yeah, I was able to figure that one out after a few tries. Thanks!


    Reply 10 days ago

    Thanks, voila! Succes! I still stand by my IT motto, all of us are smarter than just one of us..


    Reply 9 days ago

    I totally agree! The comments in the Instructables sections are often very helpful. The next best source is the Reddit HackerBoxes site and the least useful is the Discord site which is mostly just chatter among a few people who don't have much of anything useful to say. Also, if all else fails be sure to contact HackerBoxes support directly. They really are very helpful.


    Reply 14 days ago

    If the target device isn't found, then it may be an alignment problem. Mine would show the target, but say the most voltage available from usb was 4.625. When i switched to the 4.625 from the 4.875, it worked fine.


    Question 15 days ago

    I'm working on section 3 with the PICKit3 programmer connected to the ZIF socket. Its connected thru a USB 3.0 port. The program compiles correctly, but when it goes to burn to the chip, I get an error after clicking on the voltage error prompt. It reads:
    Programmer to target power is enabled - VDD = 4.875000 volts.
    Target Device ID (0x3fe0) is an Invalid Device ID. Please check your connections to the Target Device.

    Device Erased...


    The following memory area(s) will be programmed:
    program memory: start address = 0x0, end address = 0x7ff
    configuration memory
    program memory
    Address: 0 Expected Value: 2ffe Received Value: 3fff
    Failed to program device
    I've double checked all of the settings in the IDE.

    What am I missing?

    3 answers

    Answer 14 days ago

    I had exactly the same problem. Found that I had the IC in the programming socket wrong. I was off by one row. Check the attached picture carefully. Good luck!


    Reply 10 days ago

    Too many years of using a eprom programmers I think. Looking closer, i started counting at the bottom, doh. I'll try one up next. That's just weird...but it was correct. Thanks.


    Answer 14 days ago

    Have you tried to program it "in circuit" rather than using the ZIF socket?


    Question 11 days ago on Step 3

    I was not able to follow your instructions ?
    The IDE source files in the blink project box does nothing when I right click it ?

    PIC of Destiny Instructions in question.
    • Right click source files, and under new select new main.c
    • Give the c file a name like "blink"

    12 days ago

    I have programmed my PIC with success but when I breadboard the circuit nothing happens to LED when I power the circuit. How would I go about troubleshooting? tips? I know how to use my multimeter for identifying values and such but not very good for finding faults.

    Side note I have a few solder projects that don't work completely or not quite right and I'm not quite sure how to identify shorted/incomplete joints or bad/burnt up components or other problems other than visually.
    I know I'm a bit open ended above but any help would be appreciated. Thanks!

    4 replies

    Reply 11 days ago

    In your photo I can't see clearly where you have the LED (+) anode pin placed. Is it on PIC pin 2? That would be the correct output pin so make sure that the anode (+) side of the LED (longer pin) is connected to PIC pin 2 and the cathode (-) side (shorter pin) is connected to ground. Otherwise...no blinky.


    Reply 12 days ago

    I had the same problem, first make sure all the connections are made properly, then make sure that you programmed the right code. You must remember to copy the source code generated by the configuration bits ( it is sent to the OUTPUT window at the bottom of the IDE) into the empty blink.c file, and THEN copy the code box from above into the source file. make sure you #include <xc.h> at the top of the file


    Reply 11 days ago

    Thanks! I see where I missed to paste that in and also to set all the other bits off in the instructions. I fixed it in MPLAB and I'll try to reprogram the chip tomorrow. One other question the (#include <xc.h> at the top of the file) is somewhat confusing. Do you mean where it is in your code above after the config bit code or should it be the first uncommented line in the whole file. Or does it matter as long as it's before the main() function. Thanks again!


    Reply 12 days ago

    * File: blink.c
    * Author: bsp82
    * Created on March 8, 2019, 7:30 PM

    // PIC16F628A Configuration Bit Settings

    // 'C' source line config statements

    // CONFIG
    #pragma config FOSC = INTOSCIO // Oscillator Selection bits (INTOSC oscillator: I/O function on RA6/OSC2/CLKOUT pin, I/O function on RA7/OSC1/CLKIN)
    #pragma config WDTE = OFF // Watchdog Timer Enable bit (WDT disabled)
    #pragma config PWRTE = OFF // Power-up Timer Enable bit (PWRT disabled)
    #pragma config MCLRE = OFF // RA5/MCLR/VPP Pin Function Select bit (RA5/MCLR/VPP pin function is digital input, MCLR internally tied to VDD)
    #pragma config BOREN = OFF // Brown-out Detect Enable bit (BOD disabled)
    #pragma config LVP = OFF // Low-Voltage Programming Enable bit (RB4/PGM pin has digital I/O function, HV on MCLR must be used for programming)
    #pragma config CPD = OFF // Data EE Memory Code Protection bit (Data memory code protection off)
    #pragma config CP = OFF // Flash Program Memory Code Protection bit (Code protection off)

    // #pragma config statements should precede project file includes.
    // Use project enums instead of #define for ON and OFF.

    #include <xc.h>
    #define _XTAL_FREQ 4000000
    void main(void) {
    TRISA = 0b00000000;
    while (1)
    PORTAbits.RA3 = 1;
    PORTAbits.RA3 = 0;