View previous topic :: View next topic |
Author |
Message |
inservi
Joined: 13 May 2007 Posts: 128
|
|
Posted: Wed Jun 06, 2007 1:44 am |
|
|
Hello,
I assume that 'pin 5 on' is pin 5 high then led off.
Here is a very simple example. I added a sample to the use of the pre-processor for delay and pin 3.
Code: | #include <12F683.h>
#device adc=8
#FUSES NOWDT //No Watch Dog Timer
#FUSES INTRC_IO //Internal RC Osc, no CLKOUT
#FUSES NOCPD //No EE protection
#FUSES NOPROTECT //Code not protected from reading
#FUSES NOMCLR //Master Clear pin used for I/O
#FUSES PUT //Power Up Timer
#FUSES BROWNOUT //Reset when brownout detected
#FUSES NOIESO //Internal External Switch Over mode disabled
#FUSES NOFCMEN //Fail-safe clock monitor disabled
#use delay(clock=8000000)
#define pin5On output_high( PIN_A5 ) ;
#define pin5Off output_low( PIN_A5 ) ;
#define pin2On output_high( PIN_A2 ) ;
#define pin2Off output_low( PIN_A2 ) ;
#define pin3On output_high( PIN_A3 ) ;
#define pin3Off output_low( PIN_A3 ) ;
#define yourDelay 1000
void main()
{
setup_adc_ports(NO_ANALOGS|VSS_VDD);
setup_adc(ADC_OFF);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_comparator(NC_NC);
setup_vref(FALSE);
setup_oscillator(OSC_8MHZ);
while(true) {
output_high( PIN_A5 ) ;
delay_ms( yourDelay ) ;
output_low( PIN_A5 ) ;
delay_ms( yourDelay ) ;
output_high( PIN_A5 ) ;
delay_ms( yourDelay ) ;
output_low( PIN_A5 ) ;
delay_ms( yourDelay ) ;
output_high( PIN_A5 ) ;
output_high( PIN_A2 ) ;
delay_ms( yourDelay ) ;
output_low( PIN_A5 ) ;
output_low( PIN_A2 ) ;
delay_ms( yourDelay ) ;
pin3On ;
delay_ms( yourDelay ) ;
pin3Off ;
delay_ms( yourDelay ) ;
pin3On ;
delay_ms( yourDelay ) ;
pin3Off ;
delay_ms( yourDelay ) ;
}
} |
If this logique is not your, you can easily change the 'output_high' by output_low'
I suppose that your diagram is not complete because so the electronic is not right.
dro. _________________ in médio virtus |
|
|
Guest
|
|
Posted: Tue Jul 10, 2007 12:55 pm |
|
|
Inservi, I think that is close to what i need but for LED_on the output has to go low. The outpunt pins are wired to the ground of an oprocoupler and must go low to activate it.
Thanks,
RB8720 |
|
|
inservi
Joined: 13 May 2007 Posts: 128
|
|
Posted: Tue Jul 10, 2007 1:43 pm |
|
|
Hello,
You are right. you need to change "high" by "low" and "low" by "high".
Using pre-processor is a good way to control this kind of modifications.
dro. _________________ in médio virtus |
|
|
|