Discussion in "Project Help" started by    Ansh12    Mar 22, 2019.
Sun Apr 28 2019, 02:15 PM

I made a minor change, it works in Proteus.
Try the attached hex code, just in case you have a compiler problem.

Are you sure you are getting a good signal into pin RB0 ?

         RD4 = 1;  // LED ON
         __delay_ms(1000); // 
         RD4 = 0;  // LED OFF
         __delay_ms(1000); // 
         INTF = 0;


you are absolutely right. I reinstalled MPLABX IDE and my previous program is working now

Now all is working so I want to do little changes

I have one sensor when it triggered I want to start counting. How to do it ?

#pragma config FOSC = HS        // Oscillator Selection bits (HS oscillator)
#pragma config WDTE = OFF       // Watchdog Timer Enable bit (WDT disabled)
#pragma config PWRTE = OFF      // Power-up Timer Enable bit (PWRT disabled)
#pragma config BOREN = ON       // Brown-out Reset Enable bit (BOR enabled)
#pragma config LVP = OFF        // Low-Voltage (Single-Supply) In-Circuit Serial Programming Enable bit (RB3 is digital I/O, HV on MCLR must be used for programming)
#pragma config CPD = OFF        // Data EEPROM Memory Code Protection bit (Data EEPROM code protection off)
#pragma config WRT = OFF        // Flash Program Memory Write Enable bits (Write protection off; all program memory may be written to by EECON control)
#pragma config CP = OFF         // Flash Program Memory Code Protection bit (Code protection off)
#define _XTAL_FREQ 20000000 //Specify the XTAL crystal FREQ
volatile unsigned int Counter;
char Trigger;
void main(void) 
    TRISB0=1;     // encoder as input
    TRISB1=1;     // Sensor as input
    TRISD1= 0;    // LED as output
    OPTION_REG=1;  // Set Rising Edge Trigger 
    INTCON = 1;   // Enable The Global Interrupt
    INTE = 1;     // External Interrupt Enable (not INTF)
    Counter = 0;  //initial values at start up
    Trigger = 0;
    while (1)
        if(Trigger == 1)
             Trigger = 0;
             Counter = 0;
             RD1 = 1;  // LED ON
             __delay_ms(1000); // 
             RD1 = 0;  // LED OFF
void interrupt isr(void)
        INTF = 0;  // Clear interrupt flag
        Counter++;    // add 1 to the Counter
        if(Counter == 30) 
        Trigger = 1;

[ Edited Sun Apr 28 2019, 02:17 PM ]

Get Social


Powered by e107 Forum System


Fri Jan 15 2021, 10:39 PM
Adrian Baier
Monthly update for marketers business hub of  reviews of paid and free business promotion software and home made natural health remedies!Please hit the unsubscribe button below to be taken off this monthly notification list or you can subscribe to recieve follow up material  when you arrive on our main blog page of free and low cost marketing programs for online businesses HERE IS THE LINK https://bit.ly/3nxq44b
Fri Jan 15 2021, 03:31 PM
I'm no longer certain where you're getting your info, but great topic. I needs to spend some time learning much more or understanding more. Thanks for fantastic info I used to be on the lookout for this info for my mission. https://onlinegate.com/index.php?page=user&action=pub_profile&id=36335 buy essay papers online buy essay papers online
Fri Jan 15 2021, 12:52 PM
I've been browsing online greater than three hours today, but I never discovered any attention-grabbing article like yours. It is lovely price enough for me. Personally, if all webmasters and bloggers made just right content material as you did, the internet will likely be a lot more useful than ever before. https://www.vingle.net/ english essay writing service english essay writing service
Fri Jan 15 2021, 05:06 AM
Fine write ups, Kudos! Best Essay writing payforessay review
Fri Jan 15 2021, 04:52 AM
Many thanks, I appreciate it! buy research paper online buy a research paper



Thu Jun 25 2020, 03:46 PM
Mon Jun 22 2020, 03:03 PM
Tue Jun 16 2020, 05:10 PM
Sat Jun 13 2020, 09:43 PM
Thu May 21 2020, 12:44 PM
Thu May 21 2020, 01:28 AM
Wed May 20 2020, 07:05 PM
Wed May 20 2020, 11:52 AM


Guests: 74, Members: 0 ...

most ever online: 182184
(Members: , Guests: 182184) on 06 Aug 2010: 05:37 AM

Members: 38215
Newest member: Mirza123