hi guys i use a very simple code on an arduino connected to servos running my blinds
the pin input is wired from ground through a wemo maker to pin 5 which is coded to pull up the resister
as my code works at the minute when wemo is set to momentary it fires the blinds open or closed. if i set the wemo to toggle the blinds go non stop open - closed
what im looking to do now is set wemo to toggle and so my code no longer works
what needs to be changed to make arduino fire the servos to one point and hold whilst the toggle switch is on , and then fire them and hold at the other location whilst the toggle is off
the reason i need it set as toggle on and off is when im out the app has no way to tell me on my smart phone what position the blinds are in
my code as it stands: ( working on a mom switch perfectly)
//zoomkat servo button toggle test 4-28-2012
#include <Servo.h>
int button = 5; //button pin, connect to ground to move servo
int press = 0;
Servo servo;
Servo servo2;
boolean toggle = true;
void setup()
{
pinMode(button, INPUT); //arduino monitor pin state
servo.attach(7); //pin for servo control signal
servo2.attach(6); //pin for second servo signal
digitalWrite(5, HIGH); //enable pullups to make pin high
}
void loop()
{
press = digitalRead(button);
if (press == LOW)
{
if(toggle)
{
servo.writeMicroseconds(1900);
servo2.writeMicroseconds(1860);
toggle = !toggle;
}
else
{
servo.writeMicroseconds(840);
servo2.writeMicroseconds(780);
toggle = !toggle;
}
}
delay(500); //delay for debounce
}
sketch_servo.ino (780 Bytes)