fork(1) download
  1. /*membaca posisi hall sensor untuk menyalakan Led memicu Q*/
  2. //variabel yang berubah
  3. const int Q1 = 13; //PEMILIHAN KENDALI MOSFET PIOUT
  4. const int Q2 = 11; //PWM
  5. const int Q3 = 12;
  6. const int Q4 = 10; //PWM
  7. const int Q5 = 8;
  8. const int Q6 = 9; //PWM
  9.  
  10. const int S1 = 4; //PIN MASUKNYA HALL SENSOR
  11. const int S2 = 3;
  12. const int S3 = 2;
  13.  
  14. const int REMSWITCH = 5; //PIN MASANG REM
  15.  
  16. int U = 0;
  17. int V = 0;
  18. int W = 0;
  19. int H = 0;
  20. int R = 0;
  21. void setup() {
  22. pinMode(Q1, OUTPUT); // INISIALISASI YANG SEBAGAI OUTPUT
  23. pinMode(Q2, OUTPUT);
  24. pinMode(Q3, OUTPUT);
  25. pinMode(Q4, OUTPUT);
  26. pinMode(Q5, OUTPUT);
  27. pinMode(Q6, OUTPUT);
  28. pinMode(S1, INPUT); // INISIALISASI YANG SEBAGAI OUTPUT
  29. pinMode(S2, INPUT);
  30. pinMode(S3, INPUT);
  31. pinMode(REMSWITCH, INPUT);
  32. Serial.begin(9600);
  33. }
  34.  
  35. void loop() {
  36. int nilaiHall = analogRead(A0);
  37. nilaiHall = map(nilaiHall, 179, 857, 0, 255);
  38. if (nilaiHall >= 256){nilaiHall = 255;}
  39. if (nilaiHall <= -1){nilaiHall = 0;}
  40. int nilaiGas = 255 - nilaiHall;
  41. Serial.print(nilaiHall);
  42. Serial.print("%");
  43. Serial.print(" Gas");
  44. Serial.print(" PWM ");
  45. Serial.println(nilaiGas);
  46. //delay(100);
  47. int rem = digitalRead(REMSWITCH);
  48. int sensor1 = digitalRead(S1);
  49. int sensor2 = digitalRead(S2);
  50. int sensor3 = digitalRead(S3);
  51.  
  52. if (rem == LOW){R = 1;} else {R = 0;}
  53. if (sensor1 == HIGH){W = 1;} else {W = 0;}
  54. if (sensor2 == HIGH){V = 10;} else {V = 0;}
  55. if (sensor3 == HIGH){U = 100;} else {U = 0;}
  56.  
  57. if (R == 1){Serial.println("Ngerem Citt");delay(100);
  58. digitalWrite(Q6, LOW); // Rem
  59. digitalWrite(Q5, LOW);
  60. digitalWrite(Q4, LOW);
  61. digitalWrite(Q3, LOW);
  62. digitalWrite(Q2, LOW);
  63. digitalWrite(Q1, LOW);
  64. nilaiGas = 0;
  65. }
  66.  
  67. H = U + V + W;
  68. if (H == 100){Serial.print("Step1 100 ");delay(100);
  69. digitalWrite(Q6, HIGH); // Step 1
  70. digitalWrite(Q5, LOW);
  71. digitalWrite(Q4, nilaiGas);
  72. digitalWrite(Q3, LOW);
  73. digitalWrite(Q2, HIGH);
  74. digitalWrite(Q1, HIGH);
  75. }
  76. if (H == 110){Serial.print("Step2 110 ");delay(100);
  77. digitalWrite(Q6, nilaiGas); // Step 2
  78. digitalWrite(Q5, LOW);
  79. digitalWrite(Q4, HIGH);
  80. digitalWrite(Q3, LOW);
  81. digitalWrite(Q2, HIGH);
  82. digitalWrite(Q1, HIGH);
  83. }
  84. if (H == 10){Serial.print("Step3 010 ");delay(100);
  85. digitalWrite(Q6, nilaiGas); // Step 3
  86. digitalWrite(Q5, LOW);
  87. analogWrite(Q4, HIGH);
  88. digitalWrite(Q3, HIGH);
  89. digitalWrite(Q2, HIGH);
  90. digitalWrite(Q1, LOW);
  91. }
  92. if (H == 11){Serial.print("Step4 011 ");delay(100);
  93. digitalWrite(Q6, HIGH); // Step 4
  94. digitalWrite(Q5, LOW);
  95. analogWrite(Q4, HIGH);
  96. digitalWrite(Q3, HIGH);
  97. digitalWrite(Q2, nilaiGas);
  98. digitalWrite(Q1, HIGH);
  99. }
  100. if (H == 1){Serial.print("Step5 001 ");delay(100);
  101. digitalWrite(Q6, HIGH); // Step 5
  102. digitalWrite(Q5, HIGH);
  103. digitalWrite(Q4, HIGH);
  104. digitalWrite(Q3, LOW);
  105. analogWrite(Q2, nilaiGas);
  106. digitalWrite(Q1, LOW);
  107. }
  108. if (H == 101){Serial.print("Step6 101 ");delay(100);
  109. digitalWrite(Q6, HIGH); // Step 6
  110. digitalWrite(Q5, HIGH);
  111. digitalWrite(Q4, nilaiGas);
  112. digitalWrite(Q3, LOW);
  113. analogWrite(Q2, HIGH);
  114. digitalWrite(Q1, LOW);
  115. }
  116. if (H == 111){Serial.print("Hall Rusak 1 111 ");delay(100);
  117. digitalWrite(Q6, HIGH); // Bebas
  118. digitalWrite(Q5, LOW);
  119. digitalWrite(Q4, HIGH);
  120. digitalWrite(Q3, LOW);
  121. digitalWrite(Q2, HIGH);
  122. digitalWrite(Q1, LOW);
  123. }
  124. if (H == 0){Serial.print("Hall Rusak 2 000 ");delay(100);
  125. digitalWrite(Q6, HIGH); // Bebas
  126. digitalWrite(Q5, LOW);
  127. digitalWrite(Q4, HIGH);
  128. digitalWrite(Q3, LOW);
  129. digitalWrite(Q2, HIGH);
  130. digitalWrite(Q1, LOW);
  131. }
  132. //delay(100);
  133. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘void setup()’:
prog.cpp:22:15: error: ‘OUTPUT’ was not declared in this scope
   pinMode(Q1, OUTPUT); // INISIALISASI YANG SEBAGAI OUTPUT
               ^~~~~~
prog.cpp:22:3: error: ‘pinMode’ was not declared in this scope
   pinMode(Q1, OUTPUT); // INISIALISASI YANG SEBAGAI OUTPUT
   ^~~~~~~
prog.cpp:28:15: error: ‘INPUT’ was not declared in this scope
   pinMode(S1, INPUT); // INISIALISASI YANG SEBAGAI OUTPUT
               ^~~~~
prog.cpp:32:1: error: ‘Serial’ was not declared in this scope
 Serial.begin(9600);
 ^~~~~~
prog.cpp: In function ‘void loop()’:
prog.cpp:36:28: error: ‘A0’ was not declared in this scope
 int nilaiHall = analogRead(A0);
                            ^~
prog.cpp:36:17: error: ‘analogRead’ was not declared in this scope
 int nilaiHall = analogRead(A0);
                 ^~~~~~~~~~
prog.cpp:37:13: error: ‘map’ was not declared in this scope
 nilaiHall = map(nilaiHall, 179, 857, 0, 255);
             ^~~
prog.cpp:41:3: error: ‘Serial’ was not declared in this scope
   Serial.print(nilaiHall);
   ^~~~~~
prog.cpp:47:11: error: ‘digitalRead’ was not declared in this scope
 int rem = digitalRead(REMSWITCH);
           ^~~~~~~~~~~
prog.cpp:52:12: error: ‘LOW’ was not declared in this scope
 if (rem == LOW){R = 1;} else {R = 0;}
            ^~~
prog.cpp:53:16: error: ‘HIGH’ was not declared in this scope
 if (sensor1 == HIGH){W = 1;} else {W = 0;}
                ^~~~
prog.cpp:54:16: error: ‘HIGH’ was not declared in this scope
 if (sensor2 == HIGH){V = 10;} else {V = 0;}
                ^~~~
prog.cpp:55:16: error: ‘HIGH’ was not declared in this scope
 if (sensor3 == HIGH){U = 100;} else  {U = 0;}
                ^~~~
prog.cpp:57:43: error: ‘delay’ was not declared in this scope
 if (R == 1){Serial.println("Ngerem Citt");delay(100);
                                           ^~~~~
prog.cpp:58:20: error: ‘LOW’ was not declared in this scope
   digitalWrite(Q6, LOW);   // Rem
                    ^~~
prog.cpp:58:3: error: ‘digitalWrite’ was not declared in this scope
   digitalWrite(Q6, LOW);   // Rem
   ^~~~~~~~~~~~
prog.cpp:68:44: error: ‘delay’ was not declared in this scope
 if (H == 100){Serial.print("Step1  100  ");delay(100);
                                            ^~~~~
prog.cpp:69:20: error: ‘HIGH’ was not declared in this scope
   digitalWrite(Q6, HIGH);   // Step 1
                    ^~~~
prog.cpp:69:3: error: ‘digitalWrite’ was not declared in this scope
   digitalWrite(Q6, HIGH);   // Step 1
   ^~~~~~~~~~~~
prog.cpp:70:20: error: ‘LOW’ was not declared in this scope
   digitalWrite(Q5, LOW);
                    ^~~
prog.cpp:76:44: error: ‘delay’ was not declared in this scope
 if (H == 110){Serial.print("Step2  110  ");delay(100);
                                            ^~~~~
prog.cpp:77:3: error: ‘digitalWrite’ was not declared in this scope
   digitalWrite(Q6, nilaiGas);   // Step 2
   ^~~~~~~~~~~~
prog.cpp:78:20: error: ‘LOW’ was not declared in this scope
   digitalWrite(Q5, LOW);
                    ^~~
prog.cpp:79:20: error: ‘HIGH’ was not declared in this scope
   digitalWrite(Q4, HIGH);
                    ^~~~
prog.cpp:84:43: error: ‘delay’ was not declared in this scope
 if (H == 10){Serial.print("Step3  010  ");delay(100);
                                           ^~~~~
prog.cpp:85:3: error: ‘digitalWrite’ was not declared in this scope
   digitalWrite(Q6, nilaiGas);   // Step 3
   ^~~~~~~~~~~~
prog.cpp:86:20: error: ‘LOW’ was not declared in this scope
   digitalWrite(Q5, LOW);
                    ^~~
prog.cpp:87:19: error: ‘HIGH’ was not declared in this scope
   analogWrite(Q4, HIGH);
                   ^~~~
prog.cpp:87:3: error: ‘analogWrite’ was not declared in this scope
   analogWrite(Q4, HIGH);
   ^~~~~~~~~~~
prog.cpp:92:43: error: ‘delay’ was not declared in this scope
 if (H == 11){Serial.print("Step4  011  ");delay(100);
                                           ^~~~~
prog.cpp:93:20: error: ‘HIGH’ was not declared in this scope
   digitalWrite(Q6, HIGH);   // Step 4
                    ^~~~
prog.cpp:93:3: error: ‘digitalWrite’ was not declared in this scope
   digitalWrite(Q6, HIGH);   // Step 4
   ^~~~~~~~~~~~
prog.cpp:94:20: error: ‘LOW’ was not declared in this scope
   digitalWrite(Q5, LOW);
                    ^~~
prog.cpp:95:3: error: ‘analogWrite’ was not declared in this scope
   analogWrite(Q4, HIGH);
   ^~~~~~~~~~~
prog.cpp:100:41: error: ‘delay’ was not declared in this scope
 if (H == 1){Serial.print("Step5 001  ");delay(100);
                                         ^~~~~
prog.cpp:101:20: error: ‘HIGH’ was not declared in this scope
   digitalWrite(Q6, HIGH);   // Step 5
                    ^~~~
prog.cpp:101:3: error: ‘digitalWrite’ was not declared in this scope
   digitalWrite(Q6, HIGH);   // Step 5
   ^~~~~~~~~~~~
prog.cpp:104:20: error: ‘LOW’ was not declared in this scope
   digitalWrite(Q3, LOW);
                    ^~~
prog.cpp:105:3: error: ‘analogWrite’ was not declared in this scope
   analogWrite(Q2, nilaiGas);
   ^~~~~~~~~~~
prog.cpp:108:43: error: ‘delay’ was not declared in this scope
 if (H == 101){Serial.print("Step6 101  ");delay(100);
                                           ^~~~~
prog.cpp:109:20: error: ‘HIGH’ was not declared in this scope
   digitalWrite(Q6, HIGH);   // Step 6
                    ^~~~
prog.cpp:109:3: error: ‘digitalWrite’ was not declared in this scope
   digitalWrite(Q6, HIGH);   // Step 6
   ^~~~~~~~~~~~
prog.cpp:112:20: error: ‘LOW’ was not declared in this scope
   digitalWrite(Q3, LOW);
                    ^~~
prog.cpp:113:3: error: ‘analogWrite’ was not declared in this scope
   analogWrite(Q2, HIGH);
   ^~~~~~~~~~~
prog.cpp:116:50: error: ‘delay’ was not declared in this scope
 if (H == 111){Serial.print("Hall Rusak 1 111  ");delay(100);
                                                  ^~~~~
prog.cpp:117:20: error: ‘HIGH’ was not declared in this scope
   digitalWrite(Q6, HIGH);   // Bebas
                    ^~~~
prog.cpp:117:3: error: ‘digitalWrite’ was not declared in this scope
   digitalWrite(Q6, HIGH);   // Bebas
   ^~~~~~~~~~~~
prog.cpp:118:20: error: ‘LOW’ was not declared in this scope
   digitalWrite(Q5, LOW);
                    ^~~
prog.cpp:124:49: error: ‘delay’ was not declared in this scope
 if (H == 0){Serial.print("Hall Rusak 2  000  ");delay(100);
                                                 ^~~~~
prog.cpp:125:20: error: ‘HIGH’ was not declared in this scope
   digitalWrite(Q6, HIGH);   // Bebas
                    ^~~~
prog.cpp:125:3: error: ‘digitalWrite’ was not declared in this scope
   digitalWrite(Q6, HIGH);   // Bebas
   ^~~~~~~~~~~~
prog.cpp:126:20: error: ‘LOW’ was not declared in this scope
   digitalWrite(Q5, LOW);
                    ^~~
stdout
Standard output is empty