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.

Help me switch LED on for 5s and switch it off using PIC16F877A

Status
Not open for further replies.

2xling

Newbie level 4
Joined
Mar 5, 2006
Messages
5
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,331
I am a completely newbie when it comes to pic programming. May i know what to do if i want to switch an led on for 5s then switch it off? Do i need to initialised or make use of the timer in the PIC?

Thanks so much for ur help!
 

pic16f877a assembly interrupt

u dont need timer right now.but when it comes to programming i dont know which language u are studying but i suggest assembly at first.
http://www.winpicprog.co.uk/ is a good site for tutorials.
 

asm code ds1820 and pic16f877

i'm using C programming...
 

pic16f877 assembler code hex2ascii

then read some book like this one.u will do much better by studying alone.

hope that helps.if isnt look at book upload/download section.
 

pic16f877a assembly coding for a stopwatch

i need RF Protocol for PIC16F877A
so Plz help me>>>>>>>>>>>>>Thnx
 

Re: Help need PIC16F877A

2xling,
What you want to do, if you don't want to use a timer, is to set the output that your LED is connected to, then call a delay. If your delay is, say, one second, then call it five times. Then clear the output, and call the delay again. The problem with this is that your micro spends most of its time in dealy loops, which is alright, if that is all your micro has to do.
If, on the other hand, you have other things to do with the micro, you can have an interrupt which marks off a certain amount of time. In the interrupt routine, you increment a counter variable. In your main code, you compare the value of the variable to a pre calculated number. For example, if your interrupt is set to go off every 100 mSec (ten times a second) then your precalculated number would be 50. After 50 interrupts, five seconds has passed, so change the state of the output.
I hope this helps, if you have any questions, just ask.
Best wishes,
Robert
 

Re: Help need PIC16F877A

It would be better if you go for interrupts and programming in C would be easy.................:D
 

Help need PIC16F877A

it is as simple as below code (CCS C language used)...the code can b understand easily... wth basic knowledge on programming

however one prob is tht the software delay (delay_ms or delay_us) in this high level language is not really accurate, as each line of C code is not actually a line of assembly code (it might b few lines of assembly code)....

so if accurate timing is required.... use timer instead..

Code:
#include <16f877.h>
#fuses HS, NOWRT, NOWDT, NOPUT, NOBROWNOUT, NOLVP, NOCPD, NOPROTECT, NODEBUG
#use delay(clock = 20000000)
#define LED PIN_B4

main()
{
while(TRUE)
{
output_high (LED);
delay_ms(5000);
output_low (LED);
delay_ms(5000);
}
}

regards,
sp
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top