Home > Projects > Programming the PIC Microcontroller

Programming the PIC Microcontroller

Eventually, I will need a micro controller to run the motors, read the optical encoders, etc.  Using the PICKit2 programmer and low pin count evaluation board with the PIC16F690, I dived into the world of programming PIC microcontrollers along with my buddy Stephen from work.  We arrived at the following code and compiled it using MPLAB and the HiTech C plugin:

#include <htc.h>
__CONFIG(XT & WDTDIS & PWRTDIS & BORDIS & UNPROTECT);
void init(void)
{
// port directions: 1=input, 0=output
TRISC = 0b00000000;
}
char counter;
void main(void)
{
int val[16] = {
0b0000,
0b0000,
0b0000,
0b0000,

0b0000,
0b1100,
0b1000,
0b1011,
0b1000,
0b1011,
0b1000,
0b1100,
0b0000,
0b0000,
0b0000,
};

counter = 0;
init();

while (1){

PORTC = val[counter];
_delay(4000);

counter++;
if (counter > 15) {
counter =0;
}
}
}

Below you can see the Development board, along with a smiley face that can only be seen when rapidly moving the board side to side.

admin Projects

  1. No comments yet.
  1. May 24th, 2010 at 10:17 | #1