Visual C#.NET'te LCD Simülasyonu
Lcd aktaracağımız yazıları önce bilgisayarda görmemiz için bi örnek.
using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using System.Data; namespace lcd_deneme { public class Form1 : System.Windows.Forms.Form { private System.Windows.Forms.TextBox textBox1; private System.Windows.Forms.Button button1; private System.Windows.Forms.Button button2; private System.Windows.Forms.Timer timer1; private System.Windows.Forms.Label label1; private System.Windows.Forms.PictureBox led1; private System.Windows.Forms.PictureBox led0; private System.Windows.Forms.Button button3; private System.Windows.Forms.Timer timer2; private System.Windows.Forms.Button button4; private System.Windows.Forms.Button button5; private System.Windows.Forms.Label label2; private System.Windows.Forms.Button button6; private System.Windows.Forms.Timer timer3; private System.ComponentModel.IContainer components; public Form1() { InitializeComponent(); } protected override void Dispose( bool disposing ) { if( disposing ) { if (components != null) { components.Dispose(); } } base.Dispose( disposing ); } #region Windows Form Designer generated code /// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { this.components = new System.ComponentModel.Container(); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typ eof(Form1)); this.textBox1 = new System.Windows.Forms.TextBox(); this.button1 = new System.Windows.Forms.Button(); this.button2 = new System.Windows.Forms.Button(); this.timer1 = new System.Windows.Forms.Timer(this.components); this.label1 = new System.Windows.Forms.Label(); this.led1 = new System.Windows.Forms.PictureBox(); this.led0 = new System.Windows.Forms.PictureBox(); this.button3 = new System.Windows.Forms.Button(); this.timer2 = new System.Windows.Forms.Timer(this.components); this.button4 = new System.Windows.Forms.Button(); this.button5 = new System.Windows.Forms.Button(); this.label2 = new System.Windows.Forms.Label(); this.button6 = new System.Windows.Forms.Button(); this.timer3 = new System.Windows.Forms.Timer(this.components); ((System.ComponentModel.ISupportInitialize)(this.l ed1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.l ed0)).BeginInit(); this.SuspendLayout(); // // textBox1 // this.textBox1.Location = new System.Drawing.Point(248 136); this.textBox1.MaxLength = 10; this.textBox1.Name = "textBox1"; this.textBox1.Size = new System.Drawing.Size(152 20); this.textBox1.TabIndex = 2; // // button1 // this.button1.Location = new System.Drawing.Point(136 160); this.button1.Name = "button1"; this.button1.Size = new System.Drawing.Size(112 48); this.button1.TabIndex = 3; this.button1.Text = "&LCD\'ye YAZ"; this.button1.Click += new System.EventHandler(this.button1_Click); // // button2 // this.button2.Location = new System.Drawing.Point(400 160); this.button2.Name = "button2"; this.button2.Size = new System.Drawing.Size(96 48); this.button2.TabIndex = 4; this.button2.Text = "LCD\'yi Temizle"; this.button2.Click += new System.EventHandler(this.button2_Click); // // timer1 // this.timer1.Tick += new System.EventHandler(this.timer1_Tick); // // label1 // this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif" 9.75F System.Drawing.FontStyle.Bold System.Drawing.GraphicsUnit.Point ((byte)(162))); this.label1.Location = new System.Drawing.Point(112 96); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(88 16); this.label1.TabIndex = 7; this.label1.Text = "Sola kaydır"; // // led1 // this.led1.Image = ((System.Drawing.Image)(resources.GetObject("led1. Image"))); this.led1.Location = new System.Drawing.Point(600 200); this.led1.Name = "led1"; this.led1.Size = new System.Drawing.Size(8 8); this.led1.TabIndex = 8; this.led1.TabStop = false; this.led1.Visible = false; // // led0 // this.led0.Image = ((System.Drawing.Image)(resources.GetObject("led0. Image"))); this.led0.Location = new System.Drawing.Point(616 200); this.led0.Name = "led0"; this.led0.Size = new System.Drawing.Size(8 8); this.led0.TabIndex = 9; this.led0.TabStop = false; this.led0.Visible = false; // // button3 // this.button3.Location = new System.Drawing.Point(264 168); this.button3.Name = "button3"; this.button3.Size = new System.Drawing.Size(112 40); this.button3.TabIndex = 11; this.button3.Text = "Yazının tersini göster"; this.button3.Click += new System.EventHandler(this.button3_Click); // // timer2 // this.timer2.Tick += new System.EventHandler(this.timer2_Tick); // // button4 // this.button4.Location = new System.Drawing.Point(208 96); this.button4.Name = "button4"; this.button4.Size = new System.Drawing.Size(64 24); this.button4.TabIndex = 12; this.button4.Text = "<<<<"; this.button4.Click += new System.EventHandler(this.button4_Click); // // button5 // this.button5.Location = new System.Drawing.Point(384 96); this.button5.Name = "button5"; this.button5.Size = new System.Drawing.Size(64 24); this.button5.TabIndex = 13; this.button5.Text = ">>>>"; this.button5.Click += new System.EventHandler(this.button5_Click); // // label2 // this.label2.Font = new System.Drawing.Font("Microsoft Sans Serif" 9.75F System.Drawing.FontStyle.Bold System.Drawing.GraphicsUnit.Point ((byte)(162))); this.label2.Location = new System.Drawing.Point(448 96); this.label2.Name = "label2"; this.label2.Size = new System.Drawing.Size(100 16); this.label2.TabIndex = 14; this.label2.Text = "Sağa Kaydır"; // // button6 // this.button6.Location = new System.Drawing.Point(280 96); this.button6.Name = "button6"; this.button6.Size = new System.Drawing.Size(104 24); this.button6.TabIndex = 15; this.button6.Text = "Kaydırmayı durdur"; this.button6.Click += new System.EventHandler(this.button6_Click); // // timer3 // this.timer3.Tick += new System.EventHandler(this.timer3_Tick); // // Form1 // this.AcceptButton = this.button1; this.AutoScaleBaseSize = new System.Drawing.Size(5 13); this.BackColor = System.Drawing.SystemColors.Info; this.ClientSize = new System.Drawing.Size(662 299); this.Controls.Add(this.button6); this.Controls.Add(this.label2); this.Controls.Add(this.button5); this.Controls.Add(this.button4); this.Controls.Add(this.button3); this.Controls.Add(this.led0); this.Controls.Add(this.led1); this.Controls.Add(this.label1); this.Controls.Add(this.button2); this.Controls.Add(this.button1); this.Controls.Add(this.textBox1); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D; this.MaximizeBox = false; this.Name = "Form1"; this.Text = "aas"; this.Load += new System.EventHandler(this.Form1_Load); ((System.ComponentModel.ISupportInitialize)(this.l ed1)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.l ed0)).EndInit(); this.ResumeLayout(false); this.PerformLayout(); } #endregion /// <summary> /// The main entry point for the application. /// </summary> [STAThread] static void Main() { Application.Run(new Form1()); } PictureBox[]ekransatir; private void Form1_Load(object sender System.EventArgs e) { ekransatir=new PictureBox[880]; int xpos=0; int ypos=20; int width=8; int height=8; for(int i=0;i<8;i++) { for(int j=0;j<80;j++) { ekransatir[ij]=new PictureBox(); this.Controls.Add(ekransatir[ij]); ekransatir[ij].Image=led0.Image; ekransatir[ij].SetBounds(xposyposwidthheight); ekransatir[ij].Show(); xpos+=8; } xpos=0; ypos+=8; } } int[]A; public void harfsec(char karakter) { switch(karakter) { case ' ': A=new int[88]; break; case 'A': A=new int[88]{{00111100} {01000010} {01000010} {01000010} {01111110} {01000010} {01000010} {01000010}}; break; case 'B': A=new int[88]{{01111110} {01000010} {01000010} {01111100} {01111100} {01000010} {01000010} {01111110}}; break; case 'C': A=new int[88]{{01111110} {01000000} {01000000} {01000000} {01000000} {01000000} {01000000} {01111110}}; break; case 'Ç': A=new int[88]{{01111110} {01000010} {01000000} {01000000} {01000000} {01000010} {01111110} {00011000}}; break; case 'D': A=new int[88]{{01111100} {01000010} {01000010} {01000010} {01000010} {01000010} {01000010} {01111100}}; break; case 'E': A=new int[88]{{01111110} {01000000} {01000000} {01111110} {01111110} {01000000} {01000000} {01111110}}; break; case 'F': A=new int[88]{{01111110} {01000000} {01000000} {01111110} {01000000} {01000000} {01000000} {01000000}}; break; case 'G': A=new int[88]{{01111110} {01000010} {01000000} {01000000} {01001110} {01000010} {01000010} {01111110}}; break; case 'Ğ': A=new int[88]{{01000010} {00111100} {01000010} {01000010} {00111110} {00000010} {01000010} {00111100}}; break; case 'H': A=new int[88]{{01000010} {01000010} {01000010} {01111110} {01111110} {01000010} {01000010} {01000010}}; break; case 'I': A=new int[88]{{00111000} {00010000} {00010000} {00010000} {00010000} {00010000} {00010000} {00111000}}; break; case 'İ': A=new int[88]{{00010000} {00111000} {00010000} {00010000} {00010000} {00010000} {00010000} {00111000}}; break; case 'J': A=new int[88]{{00000100} {00001110} {00000100} {00000100} {00000100} {00000100} {01000100} {00111000}}; break; case 'K': A=new int[88]{{00000000} {01000100} {01001000} {01010000} {01100000} {01010000} {01001000} {01000100}}; break; case 'L': A=new int[88]{{01000000} {01000000} {01000000} {01000000} {01000000} {01000000} {01000000} {01111110}}; break; case 'M': A=new int[88]{{01000001} {01100011} {01010101} {01001001} {01000001} {01000001} {01000001} {01000001}}; break; case 'N': A=new int[88]{{01000001} {01100001} {01010001} {01001001} {01000101} {01000011} {01000001} {01000001}}; break; case 'O': A=new int[88]{{00111100} {01000010} {01000010} {01000010} {01000010} {01000010} {01000010} {00111100}}; break; case 'Ö': A=new int[88]{{00010100} {00111110} {01000001} {01000001} {01000001} {01000001} {01000001} {00111110}}; break; case'P': A=new int[88]{{01111100} {01000010} {01000010} {01111100} {01000000} {01000000} {01000000} {01000000}}; break; case 'R': A=new int[88]{{01111100} {01000010} {01000010} {01111100} {01110000} {01001000} {01000100} {01000010}}; break; case'S': A=new int[88]{{00111110} {01000000} {01000000} {00111110} {00000010} {00000010} {00000010} {01111100}}; break; case 'Ş': A=new int[88]{{00111110} {01000000} {01000000} {00111110} {00000010} {00000010} {01111100} {00011000}}; break; case 'Q'://herkes türk değil ya canımmm:)) A=new int[88]{{00111100} {01000010} {01000010} {01000010} {01000010} {01000010} {00111100} {00000010}}; break; case 'T': A=new int[88]{{11111111} {00011000} {00011000} {00011000} {00011000} {00011000} {00011000} {00011000}}; break; case 'U': A=new int[88]{{01000001} {01000001} {01000001} {01000001} {01000001} {01000001} {01000001} {00111110}}; break; case 'Ü': A=new int[88]{{00010100} {00000000} {01000001} {01000001} {01000001} {01000001} {01000001} {00111110}}; break; case 'V': A=new int[88]{{01000001} {01000001} {01000001} {01000001} {01000001} {00100010} {00010100} {00001000}}; break; case 'Y': A=new int[88]{{01000001} {00100010} {00010100} {00001000} {00001000} {00001000} {00001000} {00001000}}; break; case 'Z': A=new int[88]{{01111111} {00000010} {00000100} {00001000} {00010000} {00100000} {01000000} {01111111}}; break; case'X': A=new int[88]{{01000010} {01000010} {00100100} {00011000} {00100100} {01000010} {01000010} {01000010}}; break; case'.': A=new int[88]{{00000000} {00000000} {00000000} {00000000} {00000000} {00000000} {11000000} {11000000}}; break; case':': A=new int[88]{{00000000} {00000000} {00100000} {00100000} {00000000} {00100000} {00100000} {00000000}}; break; case '': A=new int[88]{{00000000} {00000000} {00000000} {00000000} {00000000} {00000000} {01000000} {10000000}}; break; case '/': A=new int[88]{{00000001} {00000010} {00000100} {00001000} {00010000} {00100000} {01000000} {10000000}}; break; case '!': A=new int[88]{{00011000} {00011000} {00011000} {00011000} {00011000} {00000000} {00011000} {00011000}}; break; case'(': A=new int[88]{{00000100} {00001000} {00010000} {00010000} {00010000} {00010000} {00001000} {00000100}}; break; case ')': A=new int[88]{{00000100} {00000010} {00000001} {00000001} {00000001} {00000001} {00000010} {00000100}}; break; case'^': A=new int[88]{{00001000} {00010100} {00100010} {00000000} {00000000} {00000000} {00000000} {00000000}}; break; case'*': A=new int[88]{{01000010} {00100100} {00011000} {01111110} {00011000} {00100100} {01000010} {00000000}}; break; case '#': A=new int[88]{{01000100} {01000100} {11111110} {01000100} {11111110} {01000100} {01000100} {01000100}}; break; case'?': A=new int[88]{{00011000} {00100100} {00000100} {00000100} {00001000} {00001000} {00000000} {00001000}}; break; } } private void button1_Click(object sender System.EventArgs e) { yaz(); } public void yaz() { int gonder=0; int ij; char[]gelen=textBox1.Text.ToUpper().ToCharArray(); for(i=0j=0;i<gelen.Length && j<gelen.Length;i++j++) { harfyaz(gondergelen[j]); gonder+=8; } } public void harfyaz(int achar c) { int x=a; harfsec(c); for(int i=0;i<8;i++) { x=a; for(int j=0;j<8;j++) { if(A[ij]==1) { ekransatir[ix].Image=led1.Image; } else if(A[ij]==0) { ekransatir[ix].Image=led0.Image; } x++; } } matristemizle(); } public void matristemizle() { for(int i=0;i<8;i++) { for(int j=0;j<8;j++) { A[ij]=0; } } } private void button2_Click(object sender System.EventArgs e) { try { int sutun=0; for(int i=0;i<8;i++) { sutun=0; for(int j=0;j<80;j++) { A[isutun]=0; ekransatir[ij].Image=led0.Image; sutun++; if(sutun>7) sutun=0; } } textBox1.ResetText(); if(textBox1.CanFocus) textBox1.Focus(); timer1.Stop(); timer2.Stop(); timer3.Stop(); } catch(Exception err) { string hata=err.Message; MessageBox.Show("Ekranda silinecek bir veri yok""Uyarı"MessageBoxButtons.OKMessageBoxIcon. E rror); } } private void timer1_Tick(object sender System.EventArgs e) { for(int i=0;i<8;i++) { for(int j=0;j<79;j++) { ekransatir[ij].Image=ekransatir[ij+1].Image; } } } private void timer2_Tick(object sender System.EventArgs e) { for(int i=0;i<8;i++) { for(int j=0;j<79;j++) { ekransatir[ij].Image=ekransatir[ij+1].Image; ekransatir[i79-j-1].Image=ekransatir[ij+1].Image; } } } private void button3_Click(object sender System.EventArgs e) { timer2.Start(); timer1.Stop(); timer3.Stop(); } private void button4_Click(object sender System.EventArgs e) { timer1.Start(); } private void button6_Click(object sender System.EventArgs e) { timer1.Stop(); timer2.Stop(); timer3.Stop(); } private void button5_Click(object sender System.EventArgs e) { timer3.Start(); } private void timer3_Tick(object sender System.EventArgs e) { for(int i=0;i<8;i++) { for(int j=0;j<79;j++) { ekransatir[i79-j].Image=ekransatir[i79-j-1].Image; } } } private void button7_Click(object sender System.EventArgs e) { matristemizle(); yaz(); } } } |
Bütün Zaman Ayarları WEZ +3.5 olarak düzenlenmiştir. şu Anki Saat: 01:46 AM . |