Back to Parent

// Yosser D'Avanzo
// MirrorLight.ino

int LEDpin = 9;
int IRpin = 10;
int delayms = 750;

void setup() {
  pinMode(LEDpin, OUTPUT);
  pinMode(IRpin, INPUT);

  Serial.begin(9600);
}

void loop() {
  int movement = digitalRead(IRpin);
  analogWrite(LEDpin, 0);
  Serial.println(movement);
  if( movement == 1 )
  {
    analogWrite(LEDpin, 255);
    delay(delayms);
  }
  else
  {  
    analogWrite(LEDpin, 0);
    delay(delayms);
  }

}
Click to Expand

Content Rating

Is this a good/useful/informative piece of content to include in the project? Have your say!

0