Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Register Log in

Pic16f877a push button

Status
Not open for further replies.
Joined
Apr 8, 2012
Messages
201
Helped
2
Reputation
4
Reaction score
2
Trophy points
1,298
Activity points
0
Hello!
My Circuit Contains a PIC16F877A. PIN RB0 and PB1 is connected to two mom switches with pull-ups and pin RD0 is configured as output pin and is connected to a relay via uln2003a. The mikroBasic code below is not working properly. When I press sw2 the relay gets turned ON but the relay turns off after 3-4 secs. what might be the problem.


Code Basic4GL - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
main:
     TRISB = $FF
     TRISD = $00
     PORTB = 0
     PORTD = 0
        
     while(1)
 
 
         if(Button(PORTB, 0, 10, 0)) then
            PORTD.0 = 1
         end if
        
         if(Button(PORTB, 1, 10, 0)) then
            PORTD.0 = 0
         end if



wend
 
Last edited by a moderator:

aameer

Full Member level 4
Joined
May 12, 2010
Messages
212
Helped
33
Reputation
64
Reaction score
32
Trophy points
1,308
Location
Bangalore
Activity points
2,469
i have worked in mikro C not in this IDE.
But i think it is not necessary to make PORTB=0; as it is not a output port. remove it and check.
 

hexreader

Advanced Member level 2
Joined
Apr 7, 2011
Messages
536
Helped
194
Reputation
392
Reaction score
196
Trophy points
1,323
Location
England
Activity points
4,717
My guess is that you need to disable the watchdog timer in configuration settings (edit project)
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top