Advertisement
Guest User

LOLOL

a guest
Mar 20th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. #include <Servo.h>
  2. Servo rightservo;
  3. Servo leftservo;
  4. int photocellPin=A0;
  5. int photocellVal=0;
  6. void setup() {
  7. // put your setup code here, to run once:
  8. leftservo.attach(3);
  9. rightservo.attach(9);
  10. pinMode(A0,INPUT);
  11. Serial.begin(9600);
  12. }
  13.  
  14. void loop() {
  15. photocellVal=analogRead(photocellPin);
  16. Serial.println(photocellVal);
  17. leftservo.write(40);
  18. rightservo.write(40);
  19. if (photocellVal < 300){
  20. leftservo.attach(3);
  21. rightservo.detach();}
  22. else
  23. {
  24. leftservo.detach();
  25. rightservo.attach(9);
  26. }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement