I just need the program! And why should we just do your homework for you, so just could slap a eessoo name sticker on it. And send it in in your name. This is not the way this forum work.Micropro for PIC
pic 16f877A
i just need the program
how to do the if statement
Is this your full program or just a part of it. PIC controllers need a lot configuration in order to work. And I can not see any of this in your example. Make it habit of always posting your complete code.okay
so far i was able to do a program that will make the LED ON when i press the button and keep it pressed
here is the code (the if statement)
if(portd.b0==1)
portb=255;
else
portb=0;
I do not think your program will work. Because after reset all the bits in the TRISB register are set to one. So PORTB is all input pins. Then programming PICs attention to details are very important. You can not program a PIC without the datasheet at hands. My experience is that the moment you start to assume things. You will make wrong assumptions by default. In your program start with writing 0b00000001 to the TRISB register. Instead of trisd.b0=1;is that the full program?
Rich (BB code):void main() { trisd.b0=1; portb=0; for( ; ; ) { if(portd.b0==1) portb=255; else portb=0; } }
eessooyou need to implement a finite-state machine. It's not a complicated concept. Look at you the list of states you showed us:is that the full program?
Rich (BB code):void main() { trisd.b0=1; portb=0; for( ; ; ) { if(portd.b0==1) portb=255; else portb=0; } }
OK, so when do you turn half on and half off? Answer: When the button has been pressed and your are in the "second" state.i need to make a program that work when i press a button
[1]first press make all LED ON
second press make all LED OFF
third press half on half off
forth do nothing
fifth shift right
Sixth shift left
seventh go back to [1] BUT(it dose nothing )
by Duane Benson
by Jake Hertz
by Aaron Carman