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 support@ccsinfo.com

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
rb8720



Joined: 04 Jun 2007
Posts: 13

View user's profile Send private message

Help with flashing led
PostPosted: Mon Jun 04, 2007 1:03 pm     Reply with quote

I am using the command GPIO = (1<<4) to send a signal to the led to turn it on and GPIO = 0 to turn it off. The problem is the Annode of the led has to be connected to the pin and Cathode to ground. I need to do just the opposite and flash the led with the cathode to the pin and the annode to power. What command would i use to do this.

Thanks,
rb8720
inservi



Joined: 13 May 2007
Posts: 128

View user's profile Send private message

PostPosted: Tue Jun 05, 2007 12:51 am     Reply with quote

Hello,

If you use a general purpose pin then with anode to power and cathode to the pin (with resistor) , GPIO = (1<<4) will switch the led off and GPIO = 0 will switch the led on.

for sample:
Code:

  ...
  output_high(PIN_B0);  // The led is off
  ...
  output_low(PIN_B0);  // The led is on
  ...


Best regards,
dro
_________________
in médio virtus
Guest








PostPosted: Tue Jun 05, 2007 9:10 am     Reply with quote

Inservi,

Thanks for the reply. How could I apply that to more than one pin. What I need to happen is Pin 5 on, Delay, pin 5off, delay, Pin 5 on, delay, Pinn5 off, delay, Pin5 and pin2 on, delay, pin 5 and 2 off, delay,pin 3 on, delay, pin3 off, delay pin3 on, delay pin 3 off, delay, Repeat sequence.

I have the fill doagram of how it is wired. How would i display that on here ?
rb8720



Joined: 04 Jun 2007
Posts: 13

View user's profile Send private message

PostPosted: Tue Jun 05, 2007 9:11 am     Reply with quote

BTW, I am the gues in the reply, I forgot to login.
rb8720



Joined: 04 Jun 2007
Posts: 13

View user's profile Send private message

PostPosted: Tue Jun 05, 2007 9:28 am     Reply with quote

Here is the Diagram of how the chip is wired and what it is wired to.

http://new.photos.yahoo.com/xheavenstarx/album/576460762403708787/photo/294928804414450813/0

Thanks
RB
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Tue Jun 05, 2007 9:48 am     Reply with quote

The link isn't working.
rb8720



Joined: 04 Jun 2007
Posts: 13

View user's profile Send private message

PostPosted: Tue Jun 05, 2007 2:00 pm     Reply with quote

http://new.photos.yahoo.com/xheavenstarx/album/576460762403708787/photo/294928804414450813/0

Try this one, forgot to make public.
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