Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. //lAB 5
  2. //Crhistian David Lucumi
  3. //Usc
  4. //Version 1.0
  5. int valor=0;
  6.  
  7. #define MAX 9
  8. int led[MAX]={
  9. 2, 3 , 4};
  10. int t_off=100;
  11. int t_offA=100;
  12. int t_on=100;
  13.  
  14.  
  15. void setup(){
  16. Serial.begin(9600);
  17. for(int pin=0; pin<=MAX;pin++){
  18. pinMode(led[pin], OUTPUT);
  19.  
  20. }
  21. }
  22.  
  23.  
  24. void loop(){
  25.  
  26. if (Serial.available()>0){
  27. valor=Serial.read();
  28. if (valor=='R'){
  29. t_on=Serial.parseInt();
  30. }
  31. if (valor=='G'){
  32. t_off=Serial.parseInt();
  33. }
  34.  
  35. if (valor=='B'){
  36. t_offA=Serial.parseInt();
  37. }
  38. }
  39. prender(led[0], t_on);
  40. prender(led[1], t_off);
  41. prender(led[2], t_offA);
  42. }
  43. void prender(int le, int tem){
  44. analogWrite(le, tem);
  45.  
  46. }
  47. void apagar(int le, int tem){
  48. analogWrite(le, tem);
  49.  
  50.  
  51. }