PIC16F684 - Turn ON LED on RC1 when a Switch is Pressed on RA1

Closed Thread
Results 1 to 2 of 2
  1. #1
    rohitk's Avatar
    rohitk Guest

    Default PIC16F684 - Turn ON LED on RC1 when a Switch is Pressed on RA1


    just a simple program that wud'nt work!!!

    I would appreciate if someone would help me debug.


    My Code:
    #include <htc.h>
    #define _XTAL_FREQ 4000000 // oscillator frequency for _delay()

    /***** CONFIGURATION *****/
    // ext reset, no code or data protect, no brownout detect,
    // no watchdog, power-up timer enabled, 4MHz int clock


    /***** MAIN PROGRAM *****/

    void main()
    TRISA = 0b00000010; // RA1 = Switch Input - Switch is pulled high externally to 5V
    ANSEL = 0b00000000; // RA1 = Digital Input
    TRISC = 0b00000000; // RC1 = Output
    PORTC = 0b00000000; // Initially led off
    if (RA1==1) //
    PORTC = 0b00000010; // led on - RC1

  2. #2
    Join Date
    Feb 2006
    Gilroy, CA

    Did you find this post helpful? Yes | No


    I get a lot of errors trying to compile it with PicBasic. But it looks like it is written in C. There are a lot of C forums out there though. You probably will have much better luck there.

    WARNING Line 23: Bad token "{".
    WARNING Line 29: Bad token "{".
    WARNING Line 32: Bad token "}".
    WARNING Line 33: Bad token "}".
    ERROR Line 11: Syntax error. (Untitled.pbp)
    ERROR Line 12: Syntax error. (Untitled.pbp)
    WARNING Line 12: 4000000 Numeric overflow, value truncated. (Untitled.pbp)
    ERROR Line 14: Syntax error. (Untitled.pbp)
    ERROR Line 15: Syntax error. (Untitled.pbp)
    ERROR Line 16: Syntax error. (Untitled.pbp)
    ERROR Line 18: Syntax error. (Untitled.pbp)
    ERROR Line 20: Syntax error. (Untitled.pbp)
    ERROR Line 22: Syntax error. (Untitled.pbp)
    ERROR Line 24: Syntax error. (Untitled.pbp)
    ERROR Line 25: Syntax error. (Untitled.pbp)
    ERROR Line 26: Syntax error. (Untitled.pbp)
    ERROR Line 27: Syntax error. (Untitled.pbp)
    ERROR Line 28: Syntax error. (Untitled.pbp)
    ERROR Line 30: Bad expression. (Untitled.pbp)
    ERROR Line 30: Bad expression or missing THEN. (Untitled.pbp)
    ERROR Line 30: IF without a matching ENDIF. (Untitled.pbp)
    ERROR Line 31: Syntax error. (Untitled.pbp)

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts