Jump to content
Sign in to follow this  
Myst3ry

timer

Recommended Posts

Hi guys,

 

Im a MSP430 newbie, Can i ask, is there any codes that i can do a delay?

example if nothing is detected in 30 secs , den the lights will automatically turn off.

when there is something detected, it will automatically turn on.

 

Thanks in advance

Share this post


Link to post
Share on other sites

The code to do this is very simple. There are many ways to turn on/off the light. There are many way to detect if something is here or not. Choose the way you want to do it and write the code. Not the other way around.

Share this post


Link to post
Share on other sites

For example, the logic could be something like this:

 

1. Start a 30 seconds count-down. When down to 0, turn off the light.

 

2. If something is detected, turn on the light and also re-start the 30 second count-down.

 

3. If nothing is detected, you do not need to do anything. But the 30 second count-down continues and will turn off the light when it is down to 0.

Share this post


Link to post
Share on other sites

Start timer for 30sec.

Watch for interrupt on port. If there is an interrupt, reset timer or do whatever.

When timer expires. Turn off. Go to deep sleep.

Another port interrupt can turn on and reset the timer and the cycle continues.

See my IR Remote Control example, it's pretty much what you need.

Share this post


Link to post
Share on other sites

There are lots of ways to turn on and off the light using the timer. But as far as I know, it still depends on the code. An error will appear if you have put a wrong code.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...