Web Controlled Motorized Roller Shades

well im new to the whole arduino/electronic engineering thing, but i have high hopes!

What im trying to accomplish (At the moment):

open and close the shades on command
stopping automatically where they're supposed to- mechanical limit switches
button controls located on a webpage

What i hope to do as I further my education in electronics programming:

have a fully automated system that only requires human input as an override
knows when it is day/night
temp sensor
motion sensor-knows when im in the room
door trigger-knows when i enter/leave the room


since i have absolutely no experience with any of this, but want to learn desperately , i thought it would be best to consult the experts of the interwebs.

My Hardware:

Arduino uno r3
Ethernet shield
Seeed Motor shield V.1 .......not entirely compatible with uno r3, but it works
2 window motors, only one wired at the moment
2 lever switches, going to be used as limit switches

I would really appreciate the help!!!! Total NOOB here......





Some simple web server code for a page that has buttons.

//zoomkat 3-17-12
//simple button GET server code to control servo and arduino pin 5
//for use with IDE 1.0
//open serial monitor to see what the arduino receives
//use the \ slash to escape the " in the html 
//address will look like http://192.168.1.102:84 when submited
//for use with W5100 based ethernet shields
//Powering a servo from the arduino usually DOES NOT WORK.
//note that the below bug fix may be required
// http://code.google.com/p/arduino/issues/detail?id=605 

#include <SPI.h>
#include <Ethernet.h>

//#include <Servo.h> 
//Servo myservo;  // create servo object to control a servo 

byte mac[] = { 
  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; //physical mac address
byte ip[] = { 
  192, 168, 1, 102 }; // ip in lan
byte gateway[] = { 
  192, 168, 1, 1 }; // internet access via router
byte subnet[] = { 
  255, 255, 255, 0 }; //subnet mask
EthernetServer server(84); //server port

String readString; 

//////////////////////

void setup(){

  pinMode(5, OUTPUT); //pin selected to control
  pinMode(6, OUTPUT); //pin selected to control
  pinMode(7, OUTPUT); //pin selected to control
  //start Ethernet
  Ethernet.begin(mac, ip, gateway, gateway, subnet);
  server.begin();

  //enable serial data print 
  Serial.begin(9600); 
  Serial.println("server LED test 1.0"); // so I can keep track of what is loaded
}

void loop(){
  // Create a client connection
  EthernetClient client = server.available();
  if (client) {
    while (client.connected()) {
      if (client.available()) {
        char c = client.read();

        //read char by char HTTP request
        if (readString.length() < 100) {

          //store characters to string 
          readString += c; 
          //Serial.print(c);
        } 

        //if HTTP request has ended
        if (c == '\n') {

          ///////////////
          Serial.println(readString); //print to serial monitor for debuging 

            client.println("HTTP/1.1 200 OK"); //send new page
          client.println("Content-Type: text/html");
          client.println();

          client.println("<HTML>");
          client.println("<HEAD>");
          client.println("<TITLE>Arduino GET test page</TITLE>");
          client.println("</HEAD>");
          client.println("<BODY>");

          client.println("<H1>Zoomkat's simple Arduino button</H1>");

          // DIY buttons
          client.println("<a href=\"/?on1\"\">ON</a>"); 
          client.println("<a href=\"/?off1\"\">OFF</a>
"); 

          // mousedown buttons
          client.println("
<input type=\"button\" value=\"ON\" onmousedown=\"location.href ('/?on2');\"/>"); 
          client.println("<input type=\"button\" value=\"OFF\" onmousedown=\"location.href ('/?off2');\"/>");        

          // mousedown radio buttons
          client.println("

<input type=\"radio\" value=\"ON\" onmousedown=\"location.href ('/?on3');\"\">ON</>"); 
          client.println("<input type=\"radio\" value=\"OFF\" onmousedown=\"location.href ('/?off3');\"\">OFF</>");        

          client.println("</BODY>");
          client.println("</HTML>");

          delay(1);
          //stopping client
          client.stop();

          ///////////////////// control arduino pin
          if(readString.indexOf("on1") >0) {
            digitalWrite(5, HIGH);
            Serial.println("Led on1");
          }
          if(readString.indexOf("off1") >0) {
            digitalWrite(5, LOW);
            Serial.println("Led off1");
          }

          if(readString.indexOf("on2") >0) {
            digitalWrite(6, HIGH);
            Serial.println("Led on2");
          }
          if(readString.indexOf("off2") >0) {
            digitalWrite(6, LOW);
            Serial.println("Led off2");
          }

          if(readString.indexOf("on3") >0) {
            digitalWrite(7, HIGH);
            Serial.println("Led on3");
          }
          if(readString.indexOf("off3") >0) {
            digitalWrite(7, LOW);
            Serial.println("Led off3");
          }
          //clearing string for next read
          readString="";          
        }
      }
    }
  }
}

does it matter if im not using servos, because i have dc motors with gear boxes. That is why i want to use limit switches to automatically stop the process when it detects a momentary click.

If you're using DC motors you need to know what voltage they need to give you the required performance, and what the stall current for the motor is at that voltage. Then get a power supply capable of supplying that much current plus a safety margin (I suggest 50%) and that voltage. Then choose an h-bridge motor driver capable of controlling that voltage and current which can be controlled by 5V logic. There are several Arduino-compatible motor driver shields and boards to choose from. If you only need a small current you may be able to use an Arduino clone with an integral h-bridge driver. If you haven't already chosen the motor I suggest you get one with an integral reduction gearbox (probably around 200:1 would be about right) to reduce the torque requirement and hence reduce the current requirement. With that much reduction, even a tiny motor taking a couple of hundred milliamps would give you enough torque to be in the right ball park.

You can use a simple Light Dependent Resistor (LDR) as a daylight sensor and they are very simple to connect and read, so I suggest that light-operated blinds would be a good first step for your project.

You probably could use the server code I posted along with two relays like below, setup per the bottom schematic, to control your shade motor. You probably would need an up button to energize the up relay, a down button to energize the down relay, and a stop button to deenergize both relays.

http://www.ebay.com/itm/New-5V-10A-2-Channel-Relay-Module-Shield-for-Arduino-ARM-PIC-AVR-DSP-Electronic-/390637871608?pt=LH_DefaultDomain_0&hash=item5af3d4e1f8

ok, I figured out how to do the limit switch.........HOWEVER i cant figure out how to make a web server that has a button, that will initiate the openShade function that will be terminated by limitSwitch == HIGH. can any one of you internet geniuses figure out this situation.

int pinI1=8;//define I1 interface
int pinI2=11;//define I2 interface 
int speedpinA=9;//enable motor A
int pinI3=12;//define I3 interface 
int pinI4=13;//define I4 interface 
int speedpinB=10;//enable motor B
int spead =130;//define the spead of motor
int speadDown =759;
int limitSwitch = 5;
int val =0;
 

void setup(){
  pinMode(pinI1,OUTPUT);
  pinMode(pinI2,OUTPUT);
  pinMode(speedpinA,OUTPUT);
  pinMode(pinI3,OUTPUT);
  pinMode(pinI4,OUTPUT);
  pinMode(speedpinB,OUTPUT);
  pinMode(limitSwitch, INPUT);
}
void halt()
{
   digitalWrite(speedpinA,LOW);
   digitalWrite(speedpinB,LOW);
}  
void openShade()
{
   analogWrite(speedpinA,speadDown);//input a simulation value to set the speed
   analogWrite(speedpinB,speadDown);
   digitalWrite(pinI4,LOW);//turn DC Motor B move clockwise
   digitalWrite(pinI3,HIGH);
   digitalWrite(pinI2,LOW);//turn DC Motor A move anticlockwise
   digitalWrite(pinI1,HIGH);
   
  if (val == HIGH)
  {
   halt(); 
  }  
}

void loop()
{
 val = digitalRead(limitSwitch);  
 openShade();
}