daily pastebin goal
48%
SHARE
TWEET

Photoresistor

sudoaptinstallname Sep 14th, 2018 54 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const int photo_resist=A1;
  2. int PhotoVal;
  3. const int PinLed1 = 5;
  4. const int PinLed2 = 6;
  5. const int PinLed3 = 9;
  6.  
  7. void setup() {
  8.  
  9.   // put your setup code here, to run once:
  10. Serial.begin(9600);
  11. pinMode (photo_resist, INPUT);
  12. pinMode(PinLed1, OUTPUT);
  13. pinMode(PinLed2, OUTPUT);
  14. pinMode(PinLed3, OUTPUT);
  15. }
  16.  
  17. void loop() {
  18.   // put your main code here, to run repeatedly:
  19. PhotoVal = analogRead(photo_resist);
  20. Serial.println(PhotoVal);
  21. PhotoVal = map(PhotoVal, 300,500,255,0);
  22. analogWrite(PinLed1, PhotoVal);
  23. analogWrite(PinLed2, PhotoVal);
  24. analogWrite(PinLed3, PhotoVal);
  25. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top