Professional Documents
Culture Documents
026 JulioAbiyuPutra HMI
026 JulioAbiyuPutra HMI
End Sub
Next
Next
Next
flrogressBarflrocess.Value = 8
F leflathAndName = Appl cat on.Startupflath & "\" & Now.Day & "-" &
Now.Month & "-" & Now.Year & ".xlsx"
If F le.Ex sts(F leflathAndName) Then F le.Delete(F leflathAndName)
xlWorkSheet.SaveAs(F leflathAndName)
xlWorkBook.Close()
xlApp.Ǫu t()
releaseObject(xlApp)
releaseObject(xlWorkBook)
releaseObject(xlWorkSheet)
flrogressBarflrocess.Value = 10
MsgBox("Successfully saved" & vbCrLf & "F le are saved at : " &
F leflathAndName, MsgBoxStyle.Informat on, "Informat on")
flrogressBarflrocess.V s ble = False
flrocess.Start(F leflathAndName)
ButtonSaveToExcel.He ght = 50
ButtonSaveToExcel.Text = "Save To MS Excel"
ButtonSaveToExcel.Enabled = True
ButtonStartRecord ng.Enabled = True
End Sub
flr vate Sub releaseObject(ByVal obj As Object)
Try
System.Runt me.InteropServ ces.Marshal.ReleaseComObject(obj)
obj = Noth ng
Catch ex As Except on
obj = Noth ng
F nally
GC.Collect()
End Try
End Sub
flr vate Sub T merDataLogRecord_T ck(ByVal sender As Object, ByVal e As
EventArgs) Handles T merDataLogRecord.T ck
D m LDR_1Log As Str ng
D m DT As DateT me = Now
LDR_1Log = M d(LDR_1, 3, LDR_1L)
DataGr dV ew1.Rows.Add(New Str ng() {DataGr dV ew1.RowCount, LDR_1Log,
DT.ToLongT meStr ng, DT.ToStr ng("dd-MM-yyyy")})
Me.DataGr dV ew1.F rstD splayedScroll ngRowIndex =
Me.DataGr dV ew1.RowCount - 1
Chart1.Ser es("Temperature").flo nts.AddXY(DateT me.Now.ToLongT meStr ng,
LDR_1Log)
If Chart1.Ser es(0).flo nts.Count = L m t Then
Chart1.Ser es(0).flo nts.RemoveAt(0)
End If
If fl ctureBox1.V s ble = True Then
fl ctureBox1.V s ble = False
ElseIf fl ctureBox1.V s ble = False Then
fl ctureBox1.V s ble = True
End If
End Sub
flr vate Sub T merSer al_T ck(ByVal sender As Object, ByVal e As EventArgs)
Handles T merSer al.T ck
Try
D m StrSer alIn As Str ng = Ser alflort1.ReadEx st ng
D m StrSer alInRam As Str ng
D m TB As New TextBox
TB.Mult l ne = True
TB.Text = StrSer alIn
StrSer alInRam = TB.L nes(0).Substr ng(0, 2)
If StrSer alInRam = "L1" Then
LDR_1 = TB.L nes(0)
LDR_1L = LDR_1.Length
Else
LDR_1 = LDR_1
End If
If fl ctureBox1.V s ble = True Then
fl ctureBox1.V s ble = False
ElseIf fl ctureBox1.V s ble = False Then
fl ctureBox1.V s ble = True
End If
LabelSuhu.Text = "Temp (C) = " & M d(LDR_1, 3, LDR_1L)
Catch ex As Except on
End Try
End Sub
End Class
#include <Keypad.h>
#include <Wire.h>
#include <EEPROM.h>
#include <LiquidCrystal_I2C.h>
#include <OneWire.h>
#include <DallasTemperature.h>
#define ONE_WIRE_BUS 2
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
LiquidCrystal_I2C lcd(0x27, 16, 2);
char customKey, mulaiKey;
//char stringAngka[2];
int indexKeypad = 0;
const byte ROWS = 4;
const byte COLS = 4;
char keys[ROWS][COLS] = {
{'1', '2', '3', 'A'},
{'4', '5', '6', 'B'},
{'7', '8', '9', 'C'},
{'*', '0', '#', 'D'}
};
byte rowPins[ROWS] = {11,10,9,8};
byte colPins[COLS] = {7,6,5,4};
int x = 0;
int ssr = 3; // alamati pin SSR
float sp;
float diff, temp_now;
float T_cutoff, T_cuton, nilaicd, nilaisp, nilaidiff;
Keypad customKeypad = Keypad(makeKeymap(keys), rowPins, colPins, ROWS, COLS);
void(* resetFunc) (void) = 0; //declare reset function @ address 0
void setup()
{
Serial.begin(9600);
lcd.init();
lcd.backlight();
pinMode(ssr,OUTPUT);
sp = 0;
diff = 0;
nilaisp = sp;
nilaidiff = diff;
T_cutoff = sp + (diff/2);
T_cuton = sp - (diff/2);
delay(50);
lcd.clear();
}
void loop()
{
customKey = customKeypad.getKey();
if(x == 0){
//lcd.clear();
lcd.setCursor(0,0);
lcd.print("1.SET ON-OFF");
}
if(x == 1){
lcd.clear();
lcd.setCursor(0,0);
lcd.print("2.MULAI");
}
if(x == 2){
//lcd.clear();
lcd.setCursor(0,0);
lcd.print("3.CEK ON-OFF");
}
switch(customKey)
{
case '0' ... '9':
break;
case '#':
break;
case '*':
break;
case 'A':
x++;
break;
case 'B':
x--;
break;
case 'C':
break;
case 'D':
if(x == 0){
lcd.clear();
//analogWrite(ssr,0);
setsp();
setdiff();
}
if(x == 1){
lcd.clear();
mulai();
}
if(x == 2){
lcd.clear();
//analogWrite(ssr,0);
cekonoff();
}
break;
}
if(x > 2){
x = 0;
}
if(x < 0){
x = 2;
}
}
void setdiff(){
lcd.setCursor(0,0);
lcd.print("SET DIFF ");
customKey = customKeypad.getKey();
if(customKey >= '0' && customKey <= '9')
{
diff = diff * 10 + (customKey - '0');
lcd.setCursor(0,1);
lcd.print(diff);
T_cutoff = sp + (diff/2);
T_cuton = sp - (diff/2);
}
if(customKey == '*'){
lcd.clear();
delay(1000);
nilaidiff = diff;
return;
}
setdiff();
}
void setsp(){
lcd.setCursor(0,0);
lcd.print("SET SP ");
customKey = customKeypad.getKey();
if(customKey >= '0' && customKey <= '9')
{
sp = sp * 10 + (customKey - '0');
lcd.setCursor(0,1);
lcd.print(sp);
//lcd.print(customKey);
//sp = customKey;
}
if(customKey == '*'){
lcd.clear();
delay(1000);
nilaisp = sp;
return;
}
setsp();
}
void cekonoff(){
lcd.setCursor(0,0);
lcd.print("SP = ");
lcd.print(nilaisp);
lcd.setCursor(0,1);
lcd.print("Control diff = ");
lcd.print(nilaidiff);
customKey = customKeypad.getKey();
if(customKey == '*'){
lcd.clear();
delay(1000);
return;
}
cekonoff();
}
void mulai(){
if (sp==0) {
lcd.setCursor(0, 0);
lcd.print("Mohon Set SP");
lcd.setCursor(0, 1);
lcd.print("dan Diff Dahulu");
delay(2000);
return;
}
sensors.requestTemperatures();
T_cutoff = sp + (diff/2);
T_cuton = sp - (diff/2);
temp_now = sensors.getTempCByIndex(0);
if (temp_now >= T_cutoff) {
analogWrite(ssr,0);
}
else if (temp_now <= T_cuton) {
analogWrite(ssr,255);
}
//Serial.print("DATA,TIME,");
Serial.print("L1");
Serial.println(temp_now);
lcd.setCursor(0, 0);
lcd.print("SP= ");
lcd.print(sp);
lcd.print(" ");
lcd.setCursor(0, 1);
lcd.print("Y ");
lcd.print(temp_now);
lcd.print(" ");
delay(200);
customKey = customKeypad.getKey();
if(customKey == '*'){
lcd.clear();
analogWrite(ssr,0);
resetFunc(); //call reset
delay(800);
return;
}
mulai();
}
9. Screenshot Tampilan Kode Program Arduino IDE