Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Servo.h>
- Servo rightservo;
- Servo leftservo;
- int photocellPin=A0;
- int photocellVal=0;
- void setup() {
- // put your setup code here, to run once:
- leftservo.attach(3);
- rightservo.attach(9);
- pinMode(A0,INPUT);
- Serial.begin(9600);
- }
- void loop() {
- photocellVal=analogRead(photocellPin);
- Serial.println(photocellVal);
- leftservo.write(40);
- rightservo.write(40);
- if (photocellVal < 300){
- leftservo.attach(3);
- rightservo.detach();}
- else
- {
- leftservo.detach();
- rightservo.attach(9);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement