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.Media; using System.Runtime.InteropServices; namespace Cuenta_regresiva_LPT_01 { public partial class Form1 : Form { class ControlPort { [DllImport("inpout32.dll", EntryPoint = "Out32")] public static extern void Output(int adress, int value); } public Form1() { InitializeComponent(); } SoundPlayer tic; byte cnt = 10; int displays; int unidad, decena; private void Form1_Load(object sender, EventArgs e) { ControlPort.Output(0x378, 1); } private void btnIniciar_Click(object sender, EventArgs e) { cnt = (byte)nupInicio.Value; tic = new SoundPlayer("tic-tac_loop.wav"); tic.PlayLooping(); timer1.Enabled = true; nupInicio.Enabled = false; btnIniciar.Enabled = false; } private void timer1_Tick(object sender, EventArgs e) { cnt--; lblNumero.Text = cnt.ToString("D2"); unidad = cnt % 10; decena = cnt / 10; displays = unidad << 4; displays = displays + decena; ControlPort.Output(0x378, displays); if (cnt == 0) { tic.Stop(); timer1.Enabled = false; tic = new SoundPlayer("tic-tac_end.wav"); tic.Play(); nupInicio.Enabled = true; btnIniciar.Enabled = true; } } private void nupInicio_ValueChanged(object sender, EventArgs e) { cnt = (byte)nupInicio.Value; lblNumero.Text = cnt.ToString("D2"); unidad = cnt % 10; decena = cnt / 10; displays = unidad << 4; displays = displays + decena; ControlPort.Output(0x378, displays); } } }
Descarga del archivo
Descargar archivo