Code
Code


int led1 =3;
int led2 = 4;
int led3 = 7;

int light = 8;

const int vibe = 9; 
const int fan = 10;   // for fan

int motor=11;

const int sensor = A1; // read value for velostat
int sensorValue=0;


//int ranDel; //randomizes delay on light

int interval1; //led1
long lastRecordedTime1 = 0;
int interval2; //led2
long lastRecordedTime2=0;
int interval3;//led3
long lastRecordedTime3 = 0;

int interval4;//vibe
long lastRecordedTime4=0;
int interval5;//fan
long lastRecordedTime5=0;

int interval6;//light
long lastRecordedTime6=0;

int interval7;//motor
long lastRecordedTime7=0;

void setup() {
  Serial.begin (9600);

  pinMode (led1, OUTPUT);
  pinMode (led2, OUTPUT);
  pinMode (led3, OUTPUT);
  pinMode(vibe, OUTPUT);
  pinMode (fan, OUTPUT);
  pinMode (light, OUTPUT);
//  pinMode (led0, OUTPUT);
digitalWrite (led1, LOW);
digitalWrite (led2, LOW);
digitalWrite (led3, LOW);
digitalWrite (vibe, LOW);
digitalWrite (fan, LOW);
digitalWrite (light, LOW);
digitalWrite (motor, LOW);
}

void loop() {

  sensorValue = analogRead (sensor); //read the analog in value fo
  Serial.print ("sensor = ");
  Serial.println (sensorValue);

  if (sensorValue <= 70) {
    if (millis () - lastRecordedTime1 > 3000) {
      digitalWrite (led1, HIGH);
    }
    if (millis () - lastRecordedTime2 > 5000) {
      digitalWrite (led2, HIGH);
    }
    if (millis () - lastRecordedTime3 > 7000) {
      digitalWrite (led3, HIGH);
    }

    if (millis () - lastRecordedTime4 > 9000) {
      digitalWrite (vibe, HIGH);
    }

   if (millis () - lastRecordedTime5 > 10000) {
     digitalWrite (fan, HIGH); //for fan;
  }
  if (millis () - lastRecordedTime6 > 1000) {
     digitalWrite (light, HIGH); //for light;
  }
  if (millis () - lastRecordedTime7 > 3000) {
      digitalWrite (motor, HIGH);
    }
  }
  
    else {
      digitalWrite (led1, LOW); //led
      digitalWrite (led2, LOW);
      digitalWrite (led3, LOW);
      digitalWrite (vibe, LOW);
      digitalWrite (fan, LOW);
      digitalWrite (light, LOW);
      digitalWrite (motor, LOW);
      lastRecordedTime1=millis ();
      lastRecordedTime2=millis ();
      lastRecordedTime3=millis ();
      lastRecordedTime4=millis ();
      lastRecordedTime5=millis ();
      lastRecordedTime6=millis ();
      lastRecordedTime7=millis ();
    }

}