PDA

View Full Version : need help first time user of picmicro



tekdavid
- 29th March 2005, 02:48
i have to use a pic 16f84a to make a program like the game simon says leds 1 - 4 light up in a random order the you enter the squence back to it but i im have problems using the button comand

can any help me


b5=0
L2:
button 7,0,0,4,B5,1,L4
L4:
IF PIN7 = 0 THEN LO


LO:
high 3
PAUSE 1000
LOW 3
goto L2

bbarney
- 29th March 2005, 05:02
here's a link to a complete project
http://www.talkingelectronics.com/Projects/Simon/SimonP1.html

mister_e
- 29th March 2005, 05:39
i never use Button statement. I prefer to use IF THEN or While Wend statement




TRISA=255
TRISB=0

IF PORTA.0 then ' if push button on PORTA.0 is pressed
PORTB.0=1 ' set PORTB.0 to 1
while PORTA.0 ' wait untill push button is release
wend
pause 50 ' debounce delay
endif

Be sure you refer to the great PIN... what your PIN statement refer to? Use the pin name make your code more readable or use alias



PushButton1 var PORTA.0

if PushButton1 then
' do something here
endif