Imp wake up do something and go back to sleep

Hey gents,
Ive been working on the project to make my blinds open and close, i got that done… now my wife wants the blinds open at 0800 in the morning and close at 1800, i am clueless on where to start, perhaps anyone already did something like that. Also she wishes the Servos wont open so fast like they do now, she wants them to pen slowly so they wont scare my kid :smiley:

http://electricimp.com/docs/squirrel/system/date/

this function returns a table with current date and time split out into its constituent parts (year, month, hour, min, etc.).

note month… its 0 to 11… jan is 0, dec is 11.

note hour… you would need to manage any seasonal day light saving changes

yes there would be different approaches as to how to check against set times etc. leave that up to you…

I find it easiest to work with time as a whole number. 08:00 is 800 18:00 is 1800.

So if time >= 800 and blinds closed, open them. Opposite in the evening.

Making the servo move slower can be done with a loop.

For(i=0;i<1000;i++)
{
Servo.pos(i);
Delay(50);
}

This isn’t just copy and paste, but just the idea about how it could be done. If you want it to not block the rest of the code from running, you could also make a function to set servo position, and use a timer to call that with the desired delay between each step instead.

ohhh, you guys just opened my eyes! I thank you to both of you!

Out of interest, what are you using for the mechanical side of this? Are you hacking an existing motorised blind, or are you adding a motor to a “manual” blind? Will your blind still be manually openable and closeable when imp’d up?

Peter

I made the everything from scratch, i used 7 MG995 servos to rotate the rod inside the blinds container, and the imp is operated on the battery’s and the battery’s can be charged by 5v1A charging module. And i wont be using the manual side, but i i think you still can operate the blinds manually. Let me know if i answered everything :slight_smile: P.S. The blinds i guess are heavy duty ones, 2 inch

Im sorry for double post, im trying to get my DC 2 wire motor rotate in reverse, is there a code to do that? Thank you

Reversible DC is usually done with an “H bridge” between the controller and the motor.

One method provided by imp which could be used in your case is the imp wakeup timer method: http://electricimp.com/docs/api/imp/wakeup/

This enables one to create timer events on device or in agent code. It has a resolution of 1 centisecond up to 248 days. You can have a max of 20 timer events but this is limited by amount of free memory, if used in device.

In your case I would think you would need 2 timer events. When triggered these can call your open and close functions.

If required you can cancel a timer event using http://electricimp.com/docs/api/imp/cancelwakeup/

Reversible DC is usually done with an "H bridge" between the controller and the motor.
Thank you, i got the bridge but i have issues to get it to work, so i was trying to by pass it.
One method provided by imp which could be used in your case is the imp wakeup timer method: http://electricimp.com/docs/api/imp/wakeup/

This enables one to create timer events on device or in agent code. It has a resolution of 1 centisecond up to 248 days. You can have a max of 20 timer events but this is limited by amount of free memory, if used in device.

In your case I would think you would need 2 timer events. When triggered these can call your open and close functions.

If required you can cancel a timer event using http://electricimp.com/docs/api/imp/cancelwakeup/

Oh man, i got so many things to learn :slight_smile: i got my garage door imped, my kitchen and living room blinds, and working on the door lock atm. Thank you all for your help