This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Timer help!!!

Hi
I switch the light on, and want a timer to hold the light for 5 sec.
How do I do that??
Please help!

Thanks in advance.
/Thomas

Parents
  • Hi Thomas!

    I think your using a different toolset, think that its a c51 toolset.

    Think this will work:

    unsigned int time = -5000;
            // Set timer 0 til mode 0
    	TMOD = (TMOD & 0xf0) | 0x01; // Timer mode
    	TL0 = time % 256; // Reset timer
    	TH0 = time / 256; // Reload timer
    	TR0 = 1; // Timer run
    

    cheers

Reply
  • Hi Thomas!

    I think your using a different toolset, think that its a c51 toolset.

    Think this will work:

    unsigned int time = -5000;
            // Set timer 0 til mode 0
    	TMOD = (TMOD & 0xf0) | 0x01; // Timer mode
    	TL0 = time % 256; // Reset timer
    	TH0 = time / 256; // Reload timer
    	TR0 = 1; // Timer run
    

    cheers

Children
No data