Saturday, September 18, 2004

Blinkie and the Pic

18F452, sort of rolls off your tongue however it's bit intimidating at first. it's just a black little piece of plastic and metal, perhaps there's more inside the electronic insect. I have programmed Basic stamps before and I was just as anxious about the first success as getting the PIC to work.

Here's a quick run through of the events that occurred:
Thursday, September 16th
- 9:45AM Fedex arrives with free sample chips from MicroChip(.com)
- 2:30PM Get PIC programmer and set up in Lab
- 3:05PM First LED is blinking from the simple program on the chip.

Now that the first program is working and I understand the process of getting the code onto the chip I am much more comfortable with the needed technical knowledge.

The first program was to make an LED blink. Here's the code

'---------------------------------------------------------
main:
high portd.0 'turn LED on
pause 500 'wait half second
low portd.0 'turn LED off
pause 500 'wait another half second
goto main 'loop
'---------------------------------------------------------

The code wasn't new to me but the process of using a programming environment, compiling and then writing the program to the chip was. After writing to the chip, removing it from the cradle and placing it correctly onto the breadboard was an extra step that the Basic stamp avoided.

here are some pictures of the final products.




After getting the LED to blink I added a switch to the circuit. If the button was pressed, pin B.0, the LED, pin D.0 would turn on. If released the LED would turn off. here is the code...

'---------------------------------------------------------
input portb.0
output portd.0

main:
if portb.0 = 1 then ' if the switch is closed on pin RB0
low portd.0 ' set pin RD1 low
else
high portd.0 ' set RD1 high
endif
goto main
'---------------------------------------------------------


After the switch worked I decided to stop there. I will probably do more this weekend, play with some sensors and variable resistors.

Oh, yea, ArtBot is this weekend. get there.

0 Comments:

Post a Comment

<< Home