Code Temperature Arduino 2
/*CODE ARDUINO 2 UNTUK MENGUKUR TEMPERATUR: 1. IN fRAKSINATOR 2. FRAKSINATOR 1 3. FRAKSINATOR 2 4. FRAKSINATOR 3 5. FRAKSINATOR 4 6. GAS BUANG 7. OIL OUT 8. OIL IN */ #include "max6675.h" #include <AccelStepper.h> //library motor stepper #define HALFSTEP 8 // definisi jumlah step //#include <Servo.h> //Servo servo1; //Servo servo2;
/*//T RB int ktcSO1 = 34; int ktcCS1 = 35; int ktcCLK1 = 36; MAX6675 ktc1(ktcCLK1, ktcCS1, ktcSO1);
//T Reg int ktcSO2 = 31; int ktcCS2 = 32; int ktcCLK2 = 33; MAX6675 ktc2(ktcCLK2, ktcCS2, ktcSO2);
//T riser1 int ktcSO3 = 22; int ktcCS3 = 23; int ktcCLK3 = 24; MAX6675 ktc3(ktcCLK3, ktcCS3, ktcSO3); //T riser2 int ktcSO4 = 25; int ktcCS4 = 26; int ktcCLK4 = 27; MAX6675 ktc4(ktcCLK4, ktcCS4, ktcSO4);
// T riser3 int ktcSO5 = 28; int ktcCS5 = 29; int ktcCLK5 = 30; MAX6675 ktc5(ktcCLK5, ktcCS5, ktcSO5);
///T Cyclone1 int ktcSO6 = 37; int ktcCS6 = 38; int ktcCLK6 = 39; MAX6675 ktc6(ktcCLK6, ktcCS6, ktcSO6);
//T Cyclone2 int ktcSO7 = 40; int ktcCS7 = 41; int ktcCLK7 = 42; MAX6675 ktc7(ktcCLK7, ktcCS7, ktcSO7);
//T Cyclone3 int ktcSO8 = 43; int ktcCS8 = 44; int ktcCLK8 = 45; MAX6675 ktc8(ktcCLK8, ktcCS8, ktcSO8);
//T out cyclone int ktcSO9 = 46; int ktcCS9 = 47; int ktcCLK9 = 48; MAX6675 ktc9(ktcCLK9, ktcCS9, ktcSO9); */ //T in Fraksinator int ktcSO10 = 22; int ktcCS10 = 23; int ktcCLK10 = 24; MAX6675 ktc10(ktcCLK10, ktcCS10, ktcSO10);
//T Fraksinator1 int ktcSO11 = 25; int ktcCS11 = 26; int ktcCLK11 = 27; MAX6675 ktc11(ktcCLK11, ktcCS11, ktcSO11);
//T Fraksinator2 int ktcSO12 = 28; int ktcCS12 = 29; int ktcCLK12 = 30; MAX6675 ktc12(ktcCLK12, ktcCS12, ktcSO12);
//T Fraksinator3 int ktcSO13 = 5; int ktcCS13 = 6; int ktcCLK13 = 7; MAX6675 ktc13(ktcCLK13, ktcCS13, ktcSO13);
//T Fraksinator4 int ktcSO14 = 34; int ktcCS14 = 35; int ktcCLK14 = 36; MAX6675 ktc14(ktcCLK14, ktcCS14, ktcSO14);
//T GB1 int ktcSO15 = 2; int ktcCS15= 3; int ktcCLK15 = 4; MAX6675 ktc15(ktcCLK15, ktcCS15, ktcSO15);
//T oil.out int ktcSO16 = 40; int ktcCS16 = 41; int ktcCLK16 = 42; MAX6675 ktc16(ktcCLK16, ktcCS16, ktcSO16);
//T oil.in int ktcSO17 = 43; int ktcCS17 = 44; int ktcCLK17 = 45; MAX6675 ktc17(ktcCLK17, ktcCS17, ktcSO17);
//T GB4 int ktcSO18 = 46; int ktcCS18 = 47; int ktcCLK18 = 48; MAX6675 ktc18(ktcCLK18, ktcCS18, ktcSO18);
/*float TURBINE; //pengukuran SINYAL data yang bersifat incremental const int HSensor = 2; //nama alias pada pin 2 int Calc; */ const int AnalogInput = A0; // Analog input where the resistor is placed int sensorValue = 0; float voltage, convert, pressure_pascal, pressure_bar, pressure_psi = 0.0; float t1, f1 = 0.0; unsigned long previousMillis, previousMillis1 = 0; float waktu_cuplik = 0.0; const long interval = 1500; const long interval1 = 300; /* #define motorPin1 10 // IN1 on the ULN2003 driver 1 #define motorPin2 11 // IN2 on the ULN2003 driver 1 #define motorPin3 12 // IN3 on the ULN2003 driver 1 #define motorPin4 13 // IN4 on the ULN2003 driver 1 */ // Initialize with pin sequence IN1-IN3-IN2-IN4 for using the AccelStepper with 28BYJ-48 //AccelStepper stepper1(HALFSTEP, motorPin1, motorPin3, motorPin2, motorPin4);
/*void speedrpm () //fungsi penghitungan dan interrupt { TURBINE++; //bersifat incrementing (dengan mode falling edge) }*/
void setup() { // put your setup code here, to run once: Serial.begin(9600); /* pinMode(HSensor, INPUT); //inisialisasi sebagai input Serial.begin(9600); attachInterrupt(00, speedrpm, RISING); //cara penulisan perintah interrupt */ /* stepper1.setMaxSpeed(1000.0); stepper1.setAcceleration(200.0); stepper1.setSpeed(1000); //stepper1.moveTo(-15000); /*servo1.attach(10); // Attaches servo to specified pin servo2.attach(6); servo1.write(0); servo2.write(0); */ Serial.println("CLEARDATA"); Serial.println("LABEL, WAKTU, Cuplik(s),T.inFR, T.FR1, T.FR2 , T.FR3, T.FR4, T.GB1, T.Oil.out ,T.Oil.in,T.GB4"); }
void baca_tekanan() { sensorValue = analogRead(AnalogInput); voltage = (sensorValue*5.0)/1024.0; convert = (3.0*(voltage-0.475)); pressure_pascal = (3.0*(voltage-0.475))*1000000.0; pressure_bar = pressure_pascal/10e5; pressure_psi = pressure_bar*14.5038; }
/*void baca_flowrate() { TURBINE = 00; //data awal = 0 sei(); //perintah aktifnya mode interrupt delay (1000); //nilai delay 1 detik cli(); //perintah untuk matinya program interrupt float Calc = (TURBINE / 9); //Pulsa * 60 / 7.5 }*/
void loop() { // Serial.print("suhu = "); // Serial.print(ktc.readCelsius()); // Printing temperature value over serial port // Serial.print("\t"); // baca_tekanan(); // Serial.print(convert); // Serial.print("\t"); // Serial.println(pressure_pascal); // //Serial.print("\t"); // //Serial.println(presure); // delay(500); unsigned long currentMillis = millis(); unsigned long currentMillis1 = millis(); waktu_cuplik = (float) currentMillis/1000; //sensorValue = analogRead(A12); baca_tekanan(); //baca_flowrate(); //speedrpm();
if (currentMillis - previousMillis == interval){ // Serial.print(ktc.readCelsius()); // Serial.print("\t"); // Serial.println(sensorValue);
previousMillis = currentMillis; Serial.println((String) "DATA,TIME," + waktu_cuplik + "," + ktc10.readCelsius()+ "," + ktc11.readCelsius()+ "," + ktc12.readCelsius()+ "," + ktc13.readCelsius()+ "," + ktc14.readCelsius()+ "," + ktc15.readCelsius()+ "," + ktc16.readCelsius()+ "," + ktc17.readCelsius()+ "," + ktc18.readCelsius()); //Serial.println((String) "DATA,TIME," + waktu_cuplik + "," + ktc1.readCelsius() + "," + ktc2.readCelsius() + "," + ktc3.readCelsius() + "," + ktc4.readCelsius() + "," + ktc5.readCelsius() + "," + ktc6.readCelsius() + "," + ktc7.readCelsius() + "," + ktc8.readCelsius() + "," + ktc9.readCelsius() + "," + ktc10.readCelsius()+ "," + ktc11.readCelsius()+ "," + ktc12.readCelsius()+ "," + ktc13.readCelsius()+ "," + ktc14.readCelsius()+ "," + ktc15.readCelsius()+ "," + ktc16.readCelsius()+ "," + ktc17.readCelsius()+ "," + pressure_bar ); // Serial.println((String) "DATA,TIME," + waktu_cuplik + "," + ktc1.readCelsius() + "," + ktc2.readCelsius() + "," + ktc3.readCelsius() + ","+ ktc4.readCelsius() + "," + ktc5.readCelsius() + ","+ktc6.readCelsius() + "," + ktc7.readCelsius() + "," + ktc8.readCelsius()+ "," + ktc9.readCelsius() + "," + ktc10.readCelsius() + "," + pressure_bar); /* if(ktc1.readCelsius() < 27) { //servo1.write(80); //servo2.write(80); // stepper1.moveTo(-15000); } else if(ktc1.readCelsius()<=30) { //servo1.write(45); //servo2.write(45);
} else if (ktc1.readCelsius()>30) { //servo1.write(0); //servo2.write(0);
} delay(1000); */ } }