Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

time dependent input for pic

Status
Not open for further replies.

cyberbaby

New Member
I ready made the source code of my pic project but iam puzzled in completing them. In line with this iam asking for your help in achieving my goal. Iam looking forward with your prompt assistance. Thank you....

here is the circuit

**broken link removed**

and here is my source code..

void routine();


void main()
{
TRISA = 0x1F;
TRISB = 0x00;

PORTB = 0x00;



while(1)
{
if (PORTA.F0 == 0)
{
PORTB.F5 = 1;
if (PORTA.F2 == 1)
{
delay_ms(100);
routine();
delay_ms(100);
routine();
delay_ms(100);
routine();
delay_ms(100);
routine();
delay_ms(100);
routine();
if(PORTB.F0 == 0)
PORTB.F3 = 1;
if (PORTA.F2 == 1)
{
delay_ms(100);
routine();
delay_ms(100);
routine();
delay_ms(100);
routine();
delay_ms(100);
routine();
delay_ms(100);
routine();
if(PORTB.F0 == 0)
PORTB.F2 = 1;
if (PORTA.F2 == 1)
{
delay_ms(100);
routine();
delay_ms(100);
routine();
delay_ms(100);
routine();
delay_ms(100);
routine();
delay_ms(100);
routine();
if(PORTB.F0 == 0)
PORTB.F1 = 1;
if (PORTA.F2 == 1)
{
delay_ms(100);
routine();
delay_ms(100);
routine();
delay_ms(100);
routine();
delay_ms(100);
routine();
delay_ms(100);
routine();
if(PORTB.F0 == 0)
PORTB.F0 = 0;
}
}
}
}
}
else if(PORTA.F0 == 1)
PORTB = 0x00;
}
}

void routine()
{
if (PORTA.F2 == 0)
{
PORTB.F0 = 1;
PORTB.F3 = 0;
PORTB.F2 = 0;
PORTB.F1 = 0;
}
if (PORTA.F1 == 0)
PORTB = 0x00;
if (PORTA.F0 == 1)
PORTB = 0x00;
}

this is the scenario of my project....

when you switch on the main switch that is S-ON, the led D1 will on automatically that will last only for 10 second. At this time the RX button must also be switch on within the said time,automatically the led ON will turn-on for a moment.
In 3 minutes the led D1 will turn-on again with the given time which is 10 seconds. If the Rx button wasn't switch, the led W1 will turn-on, still the led ON still function regardless the absence of RX button.
Another 3 minutes same cycle will take into place; the led D1 will turn-on and if again the RX button wasn't turn switch, the led W1 and W2 will turn-on same with the led ON who is still functioning. Same process again, within 3 minutes the led D1 turn-on last for 10 seconds, but if the Rx button was not switch, the led W1, W2 and W3 will function (on) but in this time, the led ON will turn-off automatically due to the presence of the 3 warning leds.

thank you....:)
 
Last edited:
It is good that you posted both code and schematic.

When you post code use the # icon to put it in code blocks to preserve formating. It is hard to read unformated code.

Next you need to ask a specific question. People are more willing to help you with a given problem then try to understand and debug you entire program.

Do you have a bypass cap between +5 and gnd near the processor power pins?
 
Last edited:
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top