GeldenGolem

RGB and Potentiometer Final Code

Oct 22nd, 2017
34
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. const int REDPin=11;
  2. const int GREENPin=10;
  3. const int BLUEPin=9;
  4. const int PotPin=A0;
  5. int ReadValue;
  6. int RedVal;
  7. int GreenVal;
  8. int BlueVal;
  9.  
  10. void setup()
  11. {
  12.  
  13. pinMode(REDPin, OUTPUT);
  14. pinMode(GREENPin, OUTPUT);
  15. pinMode(BLUEPin, OUTPUT);
  16. pinMode (PotPin, INPUT);
  17. Serial.begin (9660);
  18.  
  19. }
  20.  
  21. void loop()
  22. {
  23.  
  24. ReadValue=analogRead(PotPin);
  25. RedVal = map(ReadValue, 0, 1023, 255, 0);
  26. BlueVal = map(ReadValue, 0, 1023, 0, 255);
  27. GreenVal = map (ReadValue, 0, 1023, 0, 125);
  28. analogWrite (REDPin, RedVal);
  29. analogWrite(GREENPin, GreenVal);
  30. analogWrite (BLUEPin, BlueVal);
  31. delay (200);
  32. // analogWrite (REDPin, 025);
  33. // analogWrite(GREENPin, 102);
  34. // analogWrite (BLUEPin, 102);
  35. // delay (200);
  36. // analogWrite (REDPin, 127);
  37. // analogWrite(GREENPin, 102);
  38. // analogWrite (BLUEPin, 102);
  39. // delay (200);
  40.  
  41. }
Add Comment
Please, Sign In to add comment