PComp Assignment 2

Posted on September 22, 2005 at 05:19 PM by sj695

P1010020.jpg

For our second Physical Computing lab assignment we had to program a pic chip using a version of Basic.

Day 1
Last night I was able to get a LED to blink by writing the following code:

'Define the clock speed
DEFINE OSC 4

'These are the ports i'm working with
OUTPUT portb.1 '34 Pin Number
OUTPUT portb.4 '37 Pin Number
OUTPUT portb.7 '40 Pin Number

'Start Main Function
main:

    ' Turn on Port 1
    HIGH portb.1

    ' Leave on for half a second
    PAUSE 500

    'Turn off Port 1
    LOW portb.1

    'Turn off for half a second
    PAUSE 500

    ' Go back and repeat
goto main

Seems simple, but the most difficult portion of the Lab was setting up the bread board. After receiving help from other students in the lab I had the board setup in 2 hours of course I also had to solder and wire my switch (I didn't use a switch in assignment 1). The programming took about 15 minutes.

Day 2
Today I disassembled my board to make sure i knew what was going on and to aslo add and program my switch. Reassembling my board was really helpful and I feel like I have a much clearer idea of what's going on. Here is the code I used to turn the LED on and off with the switch:

input portb.0
output portd.1

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

I also added a potentiometer to fad the LED when the switch was on, I was going to attempt to start next weeks lab but decided to wait.

 

Comments

Post a comment




Remember Me?


ABOUT THIS JOURNAL

Welcome to my ITP Journal, my name is Steven Jackson and I'm currently in my first year of studies in the Interactive Telecommunications Program (ITP) at New York University.

I will be using this journal to store and document projects, exercises and notes pertaining to classes I will be taking my first and second year.

CONTACT INFO
SEARCH

CATEGORIES
ARCHIVES
RECENT ENTRIES
XML FEEDS

» RDF
» ATOM

POWERED BY

Super Powered by Movable Type 3.17