top of page

Prototype




Here is our prototype. It includes light sensors(photoresistors), servo motors, lasers, an Arduino Uno, and is wrapped in green wrapping paper.
Code
#include<Servo.h>
Servo servo1;
Servo servo2;
Servo servo3;
int photo;
int pos = 0;
int inPin = 3;
int val = 0;
void setup()
{
servo1.attach(9);
servo2.attach(11);
servo3.attach(12);
Serial.begin(9600);
}
void loop()
{
photo = analogRead(A1);
Serial.println(photo);
if(photo>100)
{
servo1.write(180);
servo2.write(0);
}
else
{
delay(2000);
servo1.write(0);
servo2.write(180);
}
val = digitalRead(inPin);
if(val==HIGH)
{
servo3.write(0);
}
else
{
delay(2000);
servo3.write(180);
}
}
bottom of page