Step 1 - Define your pins. Add a variable to each pin you want to control. ie
Switch1 var PORTA.1
LED1 = PORTA.2
Step 2 - Add variables for temporary storage ie
Var1 var Byte
Var2 var Byte
Step 3 - Add main code. Here you want to place a lot of "if then" statements to get the status of the LED's and switches (pins), then what you want the program to do when those conditions are met.
What you are trying to do is very simple in PICBasic. Dive into the help file or manual to get an idea of all the commands PICBasic has to offer. Then download some examples that have similar code to what you are trying to accomplish. You will need to study the manual for the 18f452, as they will be some configuration needed to get all the pins to do what you want them to. Here is an example of some configuration on my 18F2520:
TRISA= %11101010
TRISC = %11010000
ADCON1 = %11111111
CMCON = %00000111
OSCTUNE = %00000011
OSCCON = %11111100
SSPSTAT = %00000000
SSPCON1 = %00100001
If you get stuck, check out the FAQ, or do a search here on the site. If all else fails post you question here, and folks will help out if they think that you genually have a problem and not just want some spoon feeding. Good luck!
Bookmarks