araba göstergesi

Delphi'de kod yazma ile ilgili sorularınızı bu foruma yazabilirsiniz.
Cevapla
ak1nekin
Üye
Mesajlar: 6
Kayıt: 06 Eki 2023 07:01

araba göstergesi

Mesaj gönderen ak1nekin »

İAngularGauge1 ve İAngularGauge2 gaz butonu / vites butonu ttimer
devir hız (butona basılı tuttuğun müddetçe)
0-1 0-20
1-2 20-40
2-3 40-60
3-4 60-80
4-5 80-100
5-6 100-120


Gaz butonuna basılı tuttuğun müddetçe devir ve hız (iAngularGauge1-2) göstergeleri değişecek
devir 3'ün üzerine çıktığında 'vitesi değiştir' mesajı gelicek
vites butonuna bastığında ise hız kaldığı yerden devam ederken devir saati '1'e düşecek
hız 150'yi geçtiğinde kırmızı led (iLedRound) yanacak. Yavaşlayın mesajı gelicek
hız göstergesi 0- 200 arasında olmasına rağmen max hız 180 olacak (hız Sınırlayıcı)
gaz butonuna basılı tutma süresi (timer ile)
if kullanılacak bolca



ödevde yardım edermisiniz
ertank
Kıdemli Üye
Mesajlar: 1657
Kayıt: 12 Eyl 2015 12:45

Re: araba göstergesi

Mesaj gönderen ertank »

Merhaba,

Ödevin sizin yaptığınız ve çalışmayan kısmını paylaşabilirseniz yardımcı olmaya çalışalım.
ak1nekin
Üye
Mesajlar: 6
Kayıt: 06 Eki 2023 07:01

Re: araba göstergesi

Mesaj gönderen ak1nekin »

ertank yazdı: 17 Kas 2023 10:32 Merhaba,

Ödevin sizin yaptığınız ve çalışmayan kısmını paylaşabilirseniz yardımcı olmaya çalışalım.
ödevi yapamıyorum okadar bilgi sahibi değilim
muratturan
Üye
Mesajlar: 16
Kayıt: 22 May 2009 01:53

Re: araba göstergesi

Mesaj gönderen muratturan »

Kimse senin için oturup program yazmaz. Ama genel hatlarını yazabilirim. En üstteki var 'ın altına vites:integer, hiz:integer ve Gaz: Boolen, vites:boolean; 4 degisken tanımla. Forma button koy ve buttonunun onmousedown altına gaz:=true , onmouseup altına gaz:=false; yaz. Böylece gaza basıldigini anlarsin.
Formun oncreate olayına
vites:=1
hız:=0

Forma Timer koy. Timer 'a cift tikla altina
Vitesdurum:=true;
If hiz > 19 and vites < 2 then Vites :=false;
If hiz > 39 and vites < 3 then Vites :=false;
If hiz > 59 and vites < 4 then Vites :=false;
If hiz > 79 and vites < 5 then Vites :=false;

if vitesdurum = false then
Label1.caption := 'vites arttir';

If gaz = true and vites =true then //vites uygunsa gaza basılıyorsa
Hiz := hiz +10 ;

If gaz = false and gaz > 0 then
Begin
Hiz =hiz -5 ;
//hıza göre vitesi düsürmeyi buraya kendin yazarsın
End;



Bunlar buttona bastiginda hiz degiskenini saniyede 10 arttirir ve buttona basmayı bıraktıgında her saniye 5 azaltır. Vites uygun degilse gaz artmaz.

Bi buton koy vites arttir diye. Tiklayinca
Vites:= vites +1

Sonuc olarak Hiz degiskenini ekranda istedigin yerde kullan. Timerin altina yaz yine.
ak1nekin
Üye
Mesajlar: 6
Kayıt: 06 Eki 2023 07:01

Re: araba göstergesi

Mesaj gönderen ak1nekin »

cevapladığınız için teşekkür ederim, hocamdan yardım aldım ve yaptım. kod böyle idi.

uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.ExtCtrls, Vcl.StdCtrls, FMX.Types, iComponent,
iVCLComponent, iCustomComponent, iPositionComponent, iScaleComponent,
iGaugeComponent, iAngularGauge, iLed, iLedRound, iTimers;


type
TForm2 = class(TForm)
Memo1: TMemo;
Button1: TButton;
Button2: TButton;
iAngularGauge1: TiAngularGauge;
iAngularGauge2: TiAngularGauge;
iLedRound1: TiLedRound;
Timer1: TTimer;
procedure Button1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure Button1MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure Button2Click(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form2: TForm2;
ShowMessageFlag,isCodeExecuted,ShowMessageFlag2,ShowMessageFlag3,isCodeExecuted2,isCodeExecuted3,ableft: boolean;
const
vitesdeger = 1;

implementation

{$R *.dfm}

procedure TForm2.Button1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
if button = mbleft then

begin
Timer1.Enabled := True;
end;
end;

procedure TForm2.Button1MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
if button = mbleft then

begin
Timer1.Enabled := False;
end;
end;

procedure TForm2.Button2Click(Sender: TObject);
begin
iAngularGauge1.Position := vitesdeger;
end;

procedure TForm2.FormCreate(Sender: TObject);
begin
Timer1.Enabled := False;
end;

procedure TForm2.Timer1Timer(Sender: TObject);
begin
Memo1.Lines.Clear;
Memo1.Lines.Add('1- Araba çalıştırıldı.');
iAngularGauge2.Position := iAngularGauge2.Position + 1;

if iAngularGauge2.Position = 21 then
iAngularGauge1.Position := 2;

Memo1.Lines.Add('2- Araba hızı =' + FloatToStr(iAngularGauge2.Position) + 'değerine, vites ise = ' + FloatToStr(iAngularGauge1.Position) + 'değerine ulaştı.');

if iAngularGauge2.Position = 41 then
iAngularGauge1.Position := 3;

if iAngularGauge2.Position = 61 then
iAngularGauge1.Position := 4;

if iAngularGauge2.Position = 81 then
Timer1.Interval := 75;

if iAngularGauge2.Position = 121 then
Timer1.Interval := 90;

if iAngularGauge2.Position = 151 then
Timer1.Interval := 120;

if iAngularGauge1.Position = 4 then
if not isCodeExecuted then

begin
begin
Timer1.Enabled := False;
if not ShowMessageFlag then

begin
ShowMessage('Vitesi değiştirin.');
ShowMessageFlag := True;
end;
end;
isCodeExecuted := True;
end;
if iAngularGauge2.Position = 150 then
if not isCodeExecuted2 then

begin
begin
Timer1.Enabled := False;
if not ShowMessageFlag2 then

begin
ShowMessage('Yavaşlayınız.') ;
ShowMessageFlag2 := True;
end;
end;
isCodeExecuted2 := True;
iLedRound1.Active := True;
end;

if iAngularGauge2.Position = 180 then
if not isCodeExecuted3 then

begin
begin
Timer1.Enabled := False;
if not ShowMessageFlag3 then

begin
ShowMessage('Hızınız sınırlandırıldı.');
ShowMessageFlag3 := True;
iAngularGauge2.Position := 0;
iLedRound1.Active := False;
end;
end;
isCodeExecuted3 := True;
end;
end;

end.
Cevapla