Saturday, June 3, 2017

Target Game Phase 3

This circuit is part of a target game using a servo and a light sensor. Flashing the sensor with a flashlight or laser will triggers the target to fall.



--------------------------- Copy Code Below
#include <Servo.h>
int sensorPin = A0;
int sensorValue;
Servo myservo; //Create and instance of the Servo object

void setup()

  myservo.attach(9); //Use pin 9 for servo control
}

void loop()
{
  sensorValue = analogRead(sensorPin);
  if (sensorValue < 500)
  {
  myservo.write(180); //instruct servo to turn 180 degrees
  delay(15);
  }
  else
  {
  myservo.write(90);      
  delay(2000);
  }
}

1 comment:

  1. Hello, thank you very much for sharing this. Could you post the one that has 5 target and if all falls it is stand up again? Thank you 🙏🏻

    ReplyDelete