- This topic has 1 reply, 2 voices, and was last updated 13 years, 2 months ago by .
Viewing 2 posts - 1 through 2 (of 2 total)
Viewing 2 posts - 1 through 2 (of 2 total)
- You must be logged in to reply to this topic.
|
Electronics › Electronics › whats wrong with my coding?
below is my coding, where i used to ON and OFF 2 LEDs using 2 push button… the conditions were as below:-
– when push button 1 presed, LED 1 ON after 2.5 sec and followed by LED 2 ON after another 2.5 sec.
– when push button 2 presed LED 2 OFF after 2.5 sec and followed by LED 1 OFF after another 2,5 sec…
when i simulate using proteus, there was no found problem and it function as the condition above.. but when i applied it through hardware, the LEDs ON and OFF automatically without press push button..
pls any1 help me to identify which part of my coding hs problem.. 10q
#include <htc.h>
#include <pic.h>
//#include <delay.h>
#define _XTAL_FREQ 20000000
int count = 0;
void main()
{
TRISA = 0x11100000; // RA0 to RA2 as input, rest as output
TRISB = 0x00000000; // port B output
PORTB = 0x00; //clear portB
while (1)
{
if (RA0 == 1)
{
__delay_ms(1000); //delay 2.5 s
RB4 = 1; //LED on
__delay_ms(1000); //delay 2.5 s
RB5 = 1; //Relay on
count = 1;
}
if (RA1 == 1)
{
__delay_ms(1000); //delay 2.5 s
RB5 = 0; //Relay off
__delay_ms(1000); //delay 2.5 s
RB4 = 0; //LED off
count = 2;
}
}
}
Hi !
Can you post here your schematic
so, i can help you.