CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Help with flashing led

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
inservi



Joined: 13 May 2007
Posts: 128

View user's profile Send private message

PostPosted: Wed Jun 06, 2007 1:44 am     Reply with quote

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








PostPosted: Tue Jul 10, 2007 12:55 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Tue Jul 10, 2007 1:43 pm     Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group