Home > Electronic Tutorials > Microcontroller Tutorials > PIC 16F877A Project Tutorial > LED Blinker

PIC16F877A Microcontroller Project Tutorial

Miscellaneous Advice

You must have the PIC wired up & be able to compile & load programs to do the other tutorials.

To run the other tutorials, follow these steps:
1. Connect circuit as described.
2. Compile the example code with whatever compiler you are using.
3. Load the program onto the PIC.
4. Turn on the power to run the program

If you don’t know how to code something, look at old PIC code on the robotics lab’s computers. I have found that we need to solve similar programming problems year after year, especially when we are talking about sensor input & motor output. Chances are good that somebody already wrote it. The PIC MCU C compiler manual is a good reference too.

I recommend that you try to be neat when attaching wires & other components. Cut your wires so that they lie flat on the breadboard, not sticking up. Make sure the bare ends are long enough to make a solid connection with the breadboard – you don’t want a loose wire! Be orderly when you run wires to the various sensors & motors, too. You will have a confusing spaghetti forest when you add sensors, motors, switches, and lights.

Another good idea is to use wire colors consistently. For example, every time you have a wire going to ground, use the same color, usually black. That way, you can understand what it does with a glance. This is important when you have 50+ wires on the board. I use red for power (the + on the battery & breadboard), black for ground (the -), blue for inputs, and green for outputs.

Always double check your connections before flicking the switch. If just one wire is in the wrong position, it could disable your circuit or burn something out.

You can build your circuit with test LEDs, to make sure it is working when you turn it on. I have a power light directly connected to the battery to so I know when the circuit is on. I also have an LED controlled by the PIC. In my programs, I make the PIC turn the LED on when it starts running. That way I know that the PIC is working correctly.

The Anode of the LED goes to the +5v rail out of the regulator. The cathode of the LED goes to a current limiting resistor – any value between 220 and 1k is fine. The other end of the resistor goes to Ground. This LED should turn on at full brightness when the circuit is turned on. If the LED does not turn on, you may have the LED in backwards. If you know the LED is in correctly, and it does not turn on or turns on dimly when the power is turned on, TURN OFF YOUR CIRCUIT, and check your wiring. This most likely means there is a short somewhere with your power rails.

If you have been running the robot for a while, check the power battery voltage. If the voltage gets too low, the robot will behave strangely due to PIC doing a “brownout”.

Note: To report broken links or to submit your projects please send email to Webmaster