It's done!
I got all the parts cut out and glued together
Here you can see the tab to act as a guide for the actuator arms
I ended up having to put a small piece of wire to hold the main actuator rods together. They were moving outwards and missing the on/off switch completely.
And the final shots. In the second pic you can see the sensor shroud I made out of black foam poster board. This shields all but the internet indicator light from the light sensor.
and the final code (thanks again crenn!!)
Code:
#include*<Servo.h>
#define dropouttime 30000
#define offtime 120000
#define connecttime 180000
enum {
waitingDrop='A',
dropDetected='B',
waitingConnection='C'
};
enum{
turnOff=79,
turnOn=119
};
int photocellPin = 0;
int photocellReading;
char state = waitingDrop;
char laststate;
unsigned char servoval = turnOff;
long looptimer, servotimer;
Servo servo;
void setup()
{
Serial.begin(1200);
servo.attach(9);
servo.write(servoval);
delay(2000);
servoval = turnOn;
servo.write(servoval);
servotimer=millis();
looptimer=servotimer;
}
void loop()
{
if (((millis()-servotimer) > 50) || (state != laststate)) {
servo.write(servoval);
servotimer = millis();
}
laststate = state;
if (state == waitingDrop) {
photocellReading = analogRead(photocellPin);
Serial.print("Analog reading = ");
Serial.println(photocellReading);
servoval = turnOn;
if ((photocellReading <= 100) && ((millis()-looptimer) > dropouttime)) {
state = dropDetected;
Serial.println("Dropout detected");
looptimer = millis();
}
else if ((photocellReading > 100) && (state == waitingDrop)) {
looptimer = millis();
}
}
else if (state == dropDetected) {
servoval = turnOff;
if ((millis()-looptimer) > offtime) {
Serial.println("Turning Modem On and waiting for connection");
state = waitingConnection;
looptimer = millis();
}
}
else if (state == waitingConnection) {
servoval = turnOn;
if ((millis()-looptimer) > connecttime) {
state = waitingDrop;
Serial.println("Waiting for Dropout");
looptimer = millis();
}
}
else {
Serial.print("States: ");
Serial.print(waitingDrop);
Serial.print(dropDetected);
Serial.println(waitingConnection);
Serial.print("Invalid state: ");
Serial.println(state);
if ((millis()-looptimer) > dropouttime){
state = waitingDrop;
looptimer = millis();
}
}
}