fork download
  1. const int R=9;
  2. const int G=10;
  3. const int B=11;
  4. const int BOTO=2;
  5. const int POT=A0;
  6.  
  7. int valor=0;
  8. int polsador;
  9. int led;
  10. int val;
  11.  
  12. void setup() {
  13. Serial.begin(9600);
  14. pinMode (R, OUTPUT );
  15. pinMode (G, OUTPUT );
  16. pinMode (B, OUTPUT);
  17. pinMode (BOTO, INPUT);
  18. }
  19.  
  20. void loop() {
  21. polsador=digitalRead(BOTO);
  22. if(polsador==0)
  23. {
  24. valor=valor+1;
  25. valor=valor%3; //valors entre 0 i 2
  26. analogWrite(B, 0);
  27. analogWrite(G, 0);
  28. analogWrite(R, 0);
  29. if(valor==0)
  30. {
  31. led=9;
  32. Serial.println("red");
  33.  
  34. }
  35. else if(valor==1)
  36. {
  37. led=10;
  38. Serial.println("verd");
  39. }
  40. else if(valor==2)
  41. {
  42. led=11;
  43. Serial.println("blau");
  44. }
  45.  
  46. }
  47. val = analogRead(POT);
  48.  
  49. val = map(val, 0, 1023, 0, 255);
  50. analogWrite(led, val);
  51. Serial.println(val);
  52. delay(100);
  53. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:5:15: error: 'A0' was not declared in this scope
 const int POT=A0;  
               ^
prog.cpp: In function 'void setup()':
prog.cpp:13:3: error: 'Serial' was not declared in this scope
   Serial.begin(9600);
   ^
prog.cpp:14:15: error: 'OUTPUT' was not declared in this scope
   pinMode (R, OUTPUT );
               ^
prog.cpp:14:22: error: 'pinMode' was not declared in this scope
   pinMode (R, OUTPUT );
                      ^
prog.cpp:17:18: error: 'INPUT' was not declared in this scope
   pinMode (BOTO, INPUT);
                  ^
prog.cpp: In function 'void loop()':
prog.cpp:21:28: error: 'digitalRead' was not declared in this scope
   polsador=digitalRead(BOTO);
                            ^
prog.cpp:26:23: error: 'analogWrite' was not declared in this scope
       analogWrite(B, 0);
                       ^
prog.cpp:32:9: error: 'Serial' was not declared in this scope
         Serial.println("red");
         ^
prog.cpp:38:7: error: 'Serial' was not declared in this scope
       Serial.println("verd");
       ^
prog.cpp:43:7: error: 'Serial' was not declared in this scope
       Serial.println("blau");
       ^
prog.cpp:47:25: error: 'analogRead' was not declared in this scope
     val = analogRead(POT);
                         ^
prog.cpp:49:35: error: 'map' was not declared in this scope
     val = map(val, 0, 1023, 0, 255);
                                   ^
prog.cpp:50:25: error: 'analogWrite' was not declared in this scope
     analogWrite(led, val);
                         ^
prog.cpp:51:5: error: 'Serial' was not declared in this scope
     Serial.println(val);
     ^
prog.cpp:52:14: error: 'delay' was not declared in this scope
     delay(100);
              ^
stdout
Standard output is empty