I use keil c to write the program I have a control signal input 0v,5v,I want to let 2 LD cross light.The action is 0v input->LD1 on(LD2 off)and then 5v input->LD1 off(LD2 off),then 0v input->LD2 ON(LD1 off) and then 5v input->LD2 OFF(LD1 OFF) and continue the action and a stop signal in the LD1 and LD2 should be all off 0V--> LD1 ON LD2 OFF 5V--> LD1 OFF LD2 OFF OV--> LD1 OFF LD2 ON 5V--> LD1 OFF LD2 OFF . . .
I write a program but it can just light 1 LD and stop signal in the light won't off my program is as following:
void main(void) { SHin=1; //the 0v,5v signal stop=1; //let the stop be input LD1=1; //initial ld1 off LD2=1; // initial ld2 off LDno=0; if (stop==0) { LD1=1; LD2=1; } if(SHin==0) { LDno++; if(LDno>1) LDno=0; } else//(SHin==1) { LD1=1; LD2=1; } if(LDno==0) { LD1=0; LD2=1; } else if(LDno==1) { LD2=0; LD1=1; } please help me!! Thank you very much!!
void main(void) { SHin=1; //the 0v,5v signal stop=1; //let the stop be input LD1=1; //initial ld1 off LD2=1; // initial ld2 off LDno=0; if (stop==0) { LD1=1; LD2=1; } if(SHin==0) { LDno++; if(LDno>1) LDno=0; } else { LD1=1; LD2=1; } if(LDno==0) { LD1=0; LD2=1; } else if(LDno==1) { LD2=0; LD1=1; } <\pre> it will cross light,but it light as 0v->LD1 on LD2 off,5v->LD2 on LD1 off