niranjan23
Member level 5
- Joined
- Jan 22, 2012
- Messages
- 94
- Helped
- 3
- Reputation
- 6
- Reaction score
- 2
- Trophy points
- 1,288
- Activity points
- 2,109
Did you ever read the 89S51 datasheet chapter about IO ports? That would be probably the first step, then you'll know how to correct your circuit.
Both P1 and P2 are open drain ports with weak pull-up.
Code ASM - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 org 0000h mov p2,#00h mov p1,#00h back:mov a,p1 cjne a,#00h,on clr P2.2 clr p2.3 on:cjne a,#01h,go2 ;check whether switch 1 is pressed setb p2.2 ;turn ON the LED sjmp back go2:cjne a,#02h,back ;check whether switch 2 is pressed setb p2.3 ;turn ON the LED sjmp back end
Code ASM - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 org 0000h mov p2,#00h mov p1,#00h mov p3,#00h back:mov a,p1 cjne a,#00h,on clr P2.0 clr p2.1 on:cjne a,#01h,go2 ;check whether switch 1 is pressed setb p2.0 ;turn ON the LED sjmp back go2:cjne a,#02h,back ;check whether switch 2 is pressed setb p2.1 ;turn ON the LED sjmp back end
no, no, no!Just use 2N2222A.
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?