0% found this document useful (0 votes)
45 views3 pages

Arduino Delphi Mysql Notepad

This document contains code for a Delphi application that connects to an Arduino board via serial communication. It reads sensor data sent from the Arduino into string variables, parses the data, and inserts it into a MySQL database via a query. The data includes weight, height, BMI, and health assessment category. The user interface has buttons and labels to control the connection and display the readings.

Uploaded by

Tito Adi Nugroho
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
45 views3 pages

Arduino Delphi Mysql Notepad

This document contains code for a Delphi application that connects to an Arduino board via serial communication. It reads sensor data sent from the Arduino into string variables, parses the data, and inserts it into a MySQL database via a query. The data includes weight, height, BMI, and health assessment category. The user interface has buttons and labels to control the connection and display the readings.

Uploaded by

Tito Adi Nugroho
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

unit ARDUINO_DELPHI_MySQL;

interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DB, ZAbstractRODataset, ZAbstractDataset, ZDataset, ZConnection,
Grids, DBGrids, StdCtrls, CPort, ExtCtrls, DBCtrls,StrUtils,
ZAbstractConnection;
type
TForm1 = class(TForm)
E_Berat: TEdit;
E_tinggi: TEdit;
E_BMI: TEdit;
E_Keterangan: TEdit;
Berat: TLabel;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Button1: TButton;
Button2: TButton;
Button3: TButton;
DBGrid1: TDBGrid;
ZQuery1: TZQuery;
DataSource1: TDataSource;
DBNavigator1: TDBNavigator;
ZConnection1: TZConnection;
Edit1: TEdit;
ComPort1: TComPort;
ListBox1: TListBox;
Button4: TButton;
procedure Button1Click(Sender: TObject);
procedure ComPort1RxChar(Sender: TObject ; Count : Integer);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
D_Tinggi: String;
D_Berat: String;
D_BMI: String;
implementation
{$R *.dfm}
procedure TForm1.ComPort1RxChar(Sender: TObject ; Count : Integer);
var A, B, C, D, DataA, DataB, DataC, DataD :string;
sx :TStringList;
begin
zquery1.Edit;

repeat
begin
Comport1.ReadStr(A,1);
DataA := DataA+A;
End;
Until A='A';
sx:=TStringList.Create;
sx.Delimiter:='A';
sx.DelimitedText:=DataA;
listbox1.Items :=sx;
E_Berat.Text := Listbox1.Items[0];
zquery1.FieldValues['Berat'] := Listbox1.Items[0];
Listbox1.Clear;
repeat
begin
Comport1.ReadStr(B,1);
DataB := DataB+B;
End;
Until B='B';
sx:=TStringList.Create;
sx.Delimiter:='B';
sx.DelimitedText:=DataB;
listbox1.Items :=sx;
E_Tinggi.Text := Listbox1.Items[0];
zquery1.FieldValues['Tinggi'] := Listbox1.Items[0];
Listbox1.Clear;
repeat
begin
Comport1.ReadStr(C,1);
DataC := DataC+C;
End;
Until C='C';
sx:=TStringList.Create;
sx.Delimiter:='C';
sx.DelimitedText:=DataC;
listbox1.Items :=sx;
E_BMI.Text := Listbox1.Items[0];
zquery1.FieldValues['BMI'] := Listbox1.Items[0];
Listbox1.Clear;
repeat
begin
Comport1.ReadStr(D,1);
DataD := DataD+D;
End;
Until D='D';
sx:=TStringList.Create;
sx.Delimiter:='D';
sx.DelimitedText:=DataD;
listbox1.Items :=sx;
if Listbox1.Items[0] = '0' then
E_Keterangan.Text := 'Kurang Ideal'
else if Listbox1.Items[0]= '1' then
E_Keterangan.Text := 'Ideal'
else if Listbox1.Items[0]= '2' then
E_Keterangan.Text := 'Kelebihan berat Badan'

else if Listbox1.Items[0] = '3' then


E_Keterangan.Text := 'Obesitas';
//E_Tinggi.Text := Listbox1.Items[0];
zquery1.FieldValues['Ket'] := E_Keterangan.Text;
Listbox1.Clear;
Zquery1.UpdateRecord;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
ComPort1.ShowSetupDialog;
Zquery1.Open;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
ComPort1.Connected:=True;
Edit1.Text:='Connected';
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
ComPort1.Connected:=False;
Edit1.Text :='Disconnected';
end;
procedure TForm1.Button4Click(Sender: TObject);
begin
Zquery1.Open;
end;
end.

You might also like