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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×