Searching \ for 'Help with this code in C' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: techref.massmind.org/techref/language/index.htm?key=c
Search entire site for: 'Help with this code in C'.

Truncated match.
PICList Thread
'Help with this code in C'
1998\04\12@083612 by fcembrola

flavicon
face
Hi picsters!

I wrote a simple code using the CCS PIC Compiler,
but for some reason, it is not working. The
hardware setup is very simple. There is a single
push-button which, when pressed, grounds input pin
GP3. When this happens, in theory the LED
connected to pin GP0 should flash for 2 seconds.

What is happening in reality is that the LED
always flashes on and off for the right period of
time, as if the statement to check the input did
not exist. I tried several variations of the code
with regard to the IF statement, but with no
success. Can anybody please tell me what I am
doing wrong?

Thanks a lot,

Francesco

=== This is the code =========
#include <12C508.h>
#fuses noprotect,nowdt,intrc,mclr,put
#use delay(clock=4000000)                       // using a
4Mhz internal osc
#use standard_io(b)
short int up, down;
main ()

{
       setup_counters(rtcc_internal,rtcc_div_2);
       output_float(pin_b3);
       enable_pullups;

get_buttons:
       delay_ms(200);
       if (!input(pin_b3)) goto channel_down;
goto get_buttons;
channel_down:
       output_high(pin_b0);
       delay_ms(2000);
       output_low(pin_b0);
goto get_buttons;
}

1998\04\12@130526 by Michael Hagberg

flavicon
face
try putting at 10K pullup resister between GP3 and VCC, if this works you
may be able to increase the value to 100K or maybe even 1M.

michael

p.s. review this code segment

#define limit_switch pin_b3
#define led pin_b0

while ( true )
 {
 delay_ms ( 200 );
 if ( !input( limit_switch ))
   {
   output_high( led );
   delay_ms (2000 );
   output_low( led );
   }
 }

{Original Message removed}

1998\04\13@101907 by Larry Payne

flavicon
face
Francesco,

Check your #fuses definition. pin_b3 is the GP3/MCLR/Vpp pin.
Try NOMCLR.

regards,
Larry


{Original Message removed}

More... (looser matching)
- Last day of these posts
- In 1998 , 1999 only
- Today
- New search...