Advertisement
Guest User

Photoresitance capteur code

a guest
Nov 29th, 2018
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. const int seuil=2000;
  2.  
  3. void setup() {
  4. // put your setup code here, to run once:
  5. Serial.begin(9600);
  6. pinMode(9, OUTPUT);
  7. pinMode(7, OUTPUT);
  8. }
  9.  
  10. void loop() {
  11. // put your main code here, to run repeatedly:
  12. digitalWrite(9, HIGH);
  13. delay(1000); //DELAI AVANT DEBUT
  14. int x;
  15. x = analogRead(A0);
  16. if (x>seuil) {
  17. digitalWrite(7, HIGH); // allume le moteur
  18. }
  19. else {
  20. digitalWrite(7, LOW); // éteint le moteur
  21. }
  22. Serial.println(x);
  23. delay(10);
  24. }
  25.  
  26.  
  27.  
  28. // pin 9 = led
  29. //pin 7 = moteur on/off (transsitor)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement