-
Categories
-
Platforms
-
Content
i am trying to write c code for LED to turn on and off i am trying how to write program please check me
#include<pic/io.h>
main()
{
DDRA=0xFF; //port b as output
PBo=0; //led off
PB0=1; //led on
}
please tell me what i did wrong
At least put a 'goto' in there at the end to send it back to the beginning.
goto is frowned upon in C
At least put a 'goto' in there at the end to send it back to the beginning.
Yes, I know. That is, however, not the "GOTO"s fault. It is the programmers who recklessly use it. If you look down the chain, the assembler code or machine code a compiler generates from statements like WHILE, FOR, IF etc. breaks down to a jump instruction (mostly conditional) that is the low level equivalent of a GOTO.
If you program in a structured way, a GOTO is as good as any other control instruction. The problem is that GOTOs make it easy to leave the well paved roads of structured programming and lead you into a jungle of less than well beaten tracks.
Havin said this: Using WHILE, FOR etc. for controlling the flow of a program just makes it easier to keep discipline while hacking down your statemens.
Harald
Please try not to make people scream.
Please try not to make people scream.
PBo need to replace with PB0 and use while loop for continues LED on off. You can use some delay function for LED Turn on time and LED turn off time can define.
Right. Thread closed.Way to go resurrecting that zombie thread!!
Also obvious as already noted in post #2.PBo need to replace with PB0