Simon Package Delivery System

Look & Feel Presentation

SIMON


/*
Servo Door Code
*/

#define VERSION "1.00a0"

Servo myservo;  // create servo object to control a servo
                // a maximum of eight servo objects can be created

int pos = 0;    // variable to store the servo position

int BELL = 4;

void setup(){
  pinMode(BELL, OUTPUT);
  Serial.begin(9600);
   myservo.attach(9);
}

void loop(){
  //look for a capital D over the serial port and ring the bell if found
  if (Serial.available() > 0){
    if (Serial.read() == 'D') {
        //ring bell briefly
        digitalWrite(BELL, HIGH);
        delay(10);
        digitalWrite(BELL, LOW);

      }
    }
}

/*
Doorbell
*/

#define VERSION "1.00a0"

int BUTTON = 2;
int LED    = 11;
int count=0;
int threshold=250;

void setup(){
  pinMode (BUTTON, INPUT);
  pinMode (LED, OUTPUT);
  Serial.begin(9600);
  Serial.println('start');
}

void loop(){

  //send a capital D over the serial port if the button is pressed
  if (digitalRead(BUTTON) == HIGH){
     Serial.print('D');
     delay(10); //prevents overwhelming the serial port
  }

  // if a capital K is received back, light the feedback LED
  if (Serial.available() > 0){
    if (Serial.read() == 'K'){
      digitalWrite(LED, HIGH);
    }
  }

    if (count>threshold){
      Serial.print('O');
    }
    if(Serial.read()=='C'){
      count=0;
    }
  }

  // when the button is released, turn off the
  if ( digitalRead(BUTTON) == HIGH){
    digitalWrite(LED, LOW);
  }

}