ArmandoCircuitos
Inicio
Electronica
Programacion
Resultado
Codigo
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.Runtime.InteropServices; namespace Expansor_74165_LPT_01 { public partial class Form1 : Form { class ControlPort { [DllImport("inpout32.dll", EntryPoint = "Out32")] public static extern void Output(int adress, int value); [DllImport("inpout32.dll", EntryPoint = "Inp32")] public static extern char Input(int adress); } public Form1() { InitializeComponent(); } int puerto, i, dato; private void Form1_Load(object sender, EventArgs e) { ControlPort.Output(0x378, 0x00); } private void timer1_Tick(object sender, EventArgs e) { dato = 0; ControlPort.Output(0x378, 0x00); ControlPort.Output(0x378, 0x02); puerto = ControlPort.Input(0x379); if (puerto == 126) dato = dato + 1; for (i = 1; i <= 7; i++) { ControlPort.Output(0x378, 0x03); ControlPort.Output(0x378, 0x02); puerto = ControlPort.Input(0x379); if (puerto == 126) dato = dato + (1 << i); } lblEntradas.Text = "Port: " + dato; } } }
Descarga del archivo
Descargar archivo