ohhhh I just figured it out! face palm
heres the updated code.
#include <Servo.h>
Servo myservo;
const int buttonPin = 3;
const int buttonDoor = 2;
const int ledRED = 13; // the pin that the LED is attached to
const int ledGREEN = 12; //green led
int servopos = 180;
void setup() {
Serial.begin(9600);
myservo.attach(5); // attach servo to pin 5
// initialize the LED pin as an output:
pinMode(ledRED, OUTPUT); // led as ouput
pinMode(ledGREEN, OUTPUT); //led as output
pinMode(buttonPin, INPUT); // nitialize pushbuttonpin as input
myservo.write(servopos);
}
void loop() {
if(digitalRead (buttonDoor) == HIGH){
if(digitalRead (buttonPin) == HIGH || Serial.read() == 'T') {
if(servopos == 180) {
digitalWrite(ledGREEN, LOW);
digitalWrite(ledRED, HIGH);
Serial.println("door is locked");
myservo.write(90);
servopos = 90;
delay(300);
}
else {
digitalWrite(ledRED, LOW);
digitalWrite(ledGREEN, HIGH);
Serial.println("door is unlocked");
myservo.write(180);
servopos = 180;
delay(300);
}
}
}
}