Advertisement
Guest User

Exercise 1

a guest
Oct 18th, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.44 KB | None | 0 0
  1. const int R = 9;
  2. const int G = 11;
  3. const int B = 10;
  4. const int PhotoR = A5;
  5.  
  6. int PhotoRValue = 0;
  7.  
  8. void setup()
  9. {
  10.   pinMode(R, OUTPUT);
  11.   pinMode(G, OUTPUT);
  12.   pinMode(B, OUTPUT);
  13.  
  14.   pinMode(PhotoR, INPUT);
  15.  
  16.   analogWrite(G, 255);
  17.  
  18.  
  19. }
  20.  
  21. void loop()
  22. {
  23.   int brightness = 0;
  24.   PhotoRValue = analogRead(A5);
  25.  
  26.   brightness = PhotoRValue;
  27.  
  28.   brightness = map(brightness, 0, 1023, 0, 255);
  29.   analogWrite(G,brightness);
  30.  
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement