Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics 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.

[SOLVED] 8051 blinking led for 5 seconds and turn on led by switch

Status
Not open for further replies.
Do you understand my code? How I checked if the switch has been pressed?

Yea, you should use interrupt and timer. But make sure you understand this code as well - the one without interrupt and timer.
 

Do you understand my code? How I checked if the switch has been pressed?

Yea, you should use interrupt and timer. But make sure you understand this code as well - the one without interrupt and timer.

logically i get how it works. im just not too good when writing in C. btw why K<22?
 

You used delay(660). The problem with that is that while the LEDs are being turned on and off, the switch is not being checked. So, the switch can only be checked after every on/off sequence. What I did is that I broke that delay time into 22 parts (0 to 21). Within each part the switch is being checked. So, the delay time remains roughly the same (as 22*30 = 660), but within each delay, the switch is being checked to see the status of that pin.

Hope this helps.
Tahmid.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top