But before I disabled it, I add the line on top, compiled with no error also.
Huh... it should have errored, oh well . . . continuing onward. This lesson we will put some information into those variables and do something based upon the content of those variables.
Oh and the reason it does not work for you to have code display in a code window is you used a backslash \ it should be a forward slash /, so
Code:
@ device pic16F628A, INTRC_OSC_NOCLKOUT, wdt_on, mclr_on, lvp_off, protect_off
Define OSC 4
CMCON = 7 ' PortA = digital I/O not quite, it means Comparators off.
VRCON = 0 ' A/D Voltage reference disabled
'"lets add this so PortA does not act like a radio antenna and create Ghost problems
PortA=0
TRISA=%00000111
TRISB = %11110000 'ports7:4 inputs, ports 3:0, outputs, is that what you want?
PortB = %00000000 ' Turn pins to low state Put this before TRISB so when PortB becomes all outputs they initialize in a state set by you, instead of chance
Led1 var byte ' Led1 as a byte(8 bits) variable
myvar var word ' myvar as a word(16 bits) variable
start:
include "modedefs.bas"
begin:
for myvar = 500 to 0 step - 25 ' 500 makes word variable necessary
high PortB.0
pause 100
low PortB.0
pause 100
high PortB.1
pause 100
low PortB.1
pause 100
high PortB.2
pause 100
low PortB.2
pause 100
'goto begin
next myvar
main:
led1 = 4
'
if porta.0 = 1 then led1 = 0
if portA.1 = 1 then led1 = 5
if PortA.2 = 1 then led1 = 7
if LED1 < 2 then high portb.0
if LED1 = 5 then high portB.1
if LED1 > 5 then high PortB.2
pause 1000
portb = 0 ' this turns off the leds
goto main
end
in this code we have all of your previous code so the led chaser will chase for a while then read the PortA lines, and then perfor action based upon the values written in the variables based upon the inputs of portA storing those values into the variables.<br>This code will switch the LEDs upward pretty fast but for reasons I do not yet grasp they switch downward very slowly, but they do switch.<br> Next installment we will send variable information via serial data.
Bookmarks