Program parallel port sebagai saklar dan indikasi menyala nya led
Transcript of Program parallel port sebagai saklar dan indikasi menyala nya led
http://intelegenci.blogspot.com
PROGRAM PARALLEL PORT SEBAGAI SAKLAR DAN INDIKASI MENYALANYA LED
Gambar program baca port
TENTANG PROGRAM :
Ada enam buah komponen penting untuk program Baca port kali ini yaitu :
1. Empat buah textbox yang berwarna merah.
2. Satu buah textbox yang berwarna putih.
3. Timer.
Penjelasan :
1. Textbox yang berwarna merah akan berubah menjadi hijau seiring saklar dipindahkan dari posisi
netral / aktiv rendah ke posisi aktiv tinggi dan sebaliknya.
2. Textbox yang berwarna putih akan menampilkan bilangan desimal yang biasa digunakan untuk
untuk menghidupkan LED pada pin data (378).
3. Timer berfungsi untuk mengulang logika atau syntax perintah yang sudah dimsukkan dengan
interfal waktu tiap per 1 detik.
Catatan :
Ketika kami melakukan uji coba untuk mengakses pin status (379) dan kami mendapatkan
bilangan desimal yang unik ketika tiap kali memindahkan posisi saklar, baik memindahkan saklar satu
persatu maupun bersamaan, bilangan desimal unik ini lah yang akan menjadi penentu posisi LED yang
hidup ketika secara bersamaan saklar dihidupkan.
http://intelegenci.blogspot.com
Berdasarkan jumlahnya saklar ada empat buah dan jika diurut kan menjadi, saklar1, saklar2,
saklar3, saklar4. Dan ketika saklar ini dikombinasikan (pada aktiv tinggi), saklar 1-2, saklar 2-4, hingga
saklar dipindahkan posisinya ke aktif tinggi semua 1-2-3-4 akan memiliki nilai desimal yang berbeda dan
daftar nilai desimal tersebut sudah saya catat. Sebut saja bilangan desimal ini “data in” :
Posisi Saklar ketika dipindah-pindah
Nilai data in
0 127
1 111
2 95
3 255
4 63
1 & 2 79
1 & 3 239
1 & 4 47
2 & 3 223
2 & 4 31
3 & 4 191
1 & 2 & 3 207
1 & 3 & 4 175
2 & 3 & 4 159
1 & 2 & 4 15
1 & 2 & 3 & 4 143
http://intelegenci.blogspot.com ALGORITMA PEMROGRAMAN :
ALGORITMA PEMROGRAMAN PORT PARALLEL SEBAGAI SAKLAR
Mulai
Baca port
status (379)
Data
in1
Data
in 2
Data
in 3
Data in
Seterus nya
Hidupkan Led sesuai
data in pin status ke
pin data (378)
http://intelegenci.blogspot.com SOURCE CODE PROGRAM :
SOURCE CODE PEMROGRAMAN PORT PARALLEL SEBAGAI SAKLAR
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace WindowsFormsApplication1 { public partial class Form1 : Form { int data = 0; public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { System.Windows.Forms.Timer timer = new System.Windows.Forms.Timer(); timer.Tick += new EventHandler(timer1_Tick); } private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { System.Diagnostics.Process.Start("http://intelegenci.blogspot.com"); } private void timer1_Tick(object sender, EventArgs e) { { data = Convert.ToInt32(LPT.Input(0x379)); if (data == 111) { LPT.Output(0x378, Int32.Parse("1")); textBox2.Text = "1"; textBox1.BackColor = Color.Green; textBox3.BackColor = Color.Red; textBox4.BackColor = Color.Red; textBox5.BackColor = Color.Red; } else if (data == 95) { LPT.Output(0x378, Int32.Parse("2"));
http://intelegenci.blogspot.com textBox2.Text = "2"; textBox1.BackColor = Color.Red; textBox3.BackColor = Color.Green; textBox4.BackColor = Color.Red; textBox5.BackColor = Color.Red; } else if (data == 255) { LPT.Output(0x378, Int32.Parse("4")); textBox2.Text = "4"; textBox1.BackColor = Color.Red; textBox3.BackColor = Color.Red; textBox4.BackColor = Color.Green; textBox5.BackColor = Color.Red; } else if (data == 63) { LPT.Output(0x378, Int32.Parse("8")); textBox2.Text = "8"; textBox1.BackColor = Color.Red; textBox3.BackColor = Color.Red; textBox4.BackColor = Color.Red; textBox5.BackColor = Color.Green; } else if (data == 79) { LPT.Output(0x378, Int32.Parse("3")); textBox2.Text = "3"; textBox1.BackColor = Color.Green; textBox3.BackColor = Color.Green; textBox4.BackColor = Color.Red; textBox5.BackColor = Color.Red; } else if (data == 239) { LPT.Output(0x378, Int32.Parse("5")); textBox2.Text = "5"; textBox1.BackColor = Color.Green; textBox3.BackColor = Color.Red; textBox4.BackColor = Color.Green; textBox5.BackColor = Color.Red; } else if (data == 47) { LPT.Output(0x378, Int32.Parse("9")); textBox2.Text = "9"; textBox1.BackColor = Color.Green; textBox3.BackColor = Color.Red; textBox4.BackColor = Color.Red; textBox5.BackColor = Color.Green; }
http://intelegenci.blogspot.com else if (data == 223) { LPT.Output(0x378, Int32.Parse("6")); textBox2.Text = "6"; textBox1.BackColor = Color.Red; textBox3.BackColor = Color.Green; textBox4.BackColor = Color.Green; textBox5.BackColor = Color.Red; } else if (data == 31) { LPT.Output(0x378, Int32.Parse("10")); textBox2.Text = "10"; textBox1.BackColor = Color.Red; textBox3.BackColor = Color.Green; textBox4.BackColor = Color.Red; textBox5.BackColor = Color.Green; } else if (data == 191) { LPT.Output(0x378, Int32.Parse("12")); textBox2.Text = "12"; textBox1.BackColor = Color.Red; textBox3.BackColor = Color.Red; textBox4.BackColor = Color.Green; textBox5.BackColor = Color.Green; } else if (data == 175) { LPT.Output(0x378, Int32.Parse("13")); textBox2.Text = "13"; textBox1.BackColor = Color.Green; textBox3.BackColor = Color.Red; textBox4.BackColor = Color.Green; textBox5.BackColor = Color.Green; } else if (data == 207) { LPT.Output(0x378, Int32.Parse("7")); textBox2.Text = "7"; textBox1.BackColor = Color.Green; textBox3.BackColor = Color.Green; textBox4.BackColor = Color.Green; textBox5.BackColor = Color.Red; } else if (data == 159) { LPT.Output(0x378, Int32.Parse("14")); textBox2.Text = "14"; textBox1.BackColor = Color.Red; textBox3.BackColor = Color.Green; textBox4.BackColor = Color.Green;
http://intelegenci.blogspot.com textBox5.BackColor = Color.Green; } else if (data == 15) { LPT.Output(0x378, Int32.Parse("11")); textBox2.Text = "11"; textBox1.BackColor = Color.Green; textBox3.BackColor = Color.Green; textBox4.BackColor = Color.Red; textBox5.BackColor = Color.Green; } else if (data == 127) { LPT.Output(0x378, Int32.Parse("0")); textBox2.Text = "0"; textBox1.BackColor = Color.Red; textBox3.BackColor = Color.Red; textBox4.BackColor = Color.Red; textBox5.BackColor = Color.Red; } else if (data == 143) { LPT.Output(0x378, Int32.Parse("15")); textBox2.Text = "15"; textBox1.BackColor = Color.Green; textBox3.BackColor = Color.Green; textBox4.BackColor = Color.Green; textBox5.BackColor = Color.Green; } } } } }