daily pastebin goal
66%
SHARE
TWEET

Untitled

a guest Mar 13th, 2018 54 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. namespace Morse
  2. {
  3. public partial class Form1 : Form
  4. {
  5.     int dit;
  6.     int rest;
  7.     int dah;
  8.     string batch;
  9.     string key;
  10.     int A;
  11.     int len;
  12.     int dah2;
  13.     bool xmit = false;
  14.     //public ushort freq = 1500;
  15.  
  16.     SerialPort myport = new System.IO.Ports.SerialPort("COM4", 9600, System.IO.Ports.Parity.None, 8, System.IO.Ports.StopBits.One);
  17.     public Form1()
  18.     {
  19.         InitializeComponent();
  20.     }
  21.     public void button1_Click(object sender, EventArgs e)
  22.     {
  23.         dit = Convert.ToInt32(50000 / Convert.ToInt32(numericUpDown1.Value * 50));
  24.         rest = Convert.ToInt32(dit);
  25.         dah = Convert.ToInt32(3 * dit);
  26.         dah2 = Convert.ToInt32(dit);
  27.  
  28.         Code();
  29.     }
  30.  
  31.     private void Code()
  32.     {
  33.  
  34.         batch = textBox1.Text.ToUpper();
  35.         len = batch.Length;
  36.  
  37.         for (A = 1; (A <= len); A++)
  38.         {
  39.             key = batch.Substring((A - 1), 0);
  40.  
  41.  
  42.  
  43.             if ((key == " "))
  44.             {
  45.                 Thread.Sleep(dit * 8);
  46.             }
  47.  
  48.  
  49.             if ((key == "A"))
  50.             {
  51.                 myport.Open();
  52.                 myport.RtsEnable = true;
  53.                 Thread.Sleep(dit);
  54.                 myport.RtsEnable = false;
  55.                 Thread.Sleep(rest);
  56.                 myport.RtsEnable = true;
  57.                 Thread.Sleep(dah);
  58.                 myport.RtsEnable = false;
  59.                 Thread.Sleep(dah2);
  60.                 myport.Close();
  61.  
  62.             }
  63.             else if ((key == "B"))
  64.             {
  65.                 myport.Open();
  66.                 myport.RtsEnable = true;
  67.                 Thread.Sleep(dah);
  68.                 myport.RtsEnable = false;
  69.                 Thread.Sleep(rest);
  70.                 myport.RtsEnable = true;
  71.                 Thread.Sleep(dit);
  72.                 myport.RtsEnable = false;
  73.                 Thread.Sleep(rest);
  74.                 myport.RtsEnable = true;
  75.                 Thread.Sleep(dit);
  76.                 myport.RtsEnable = false;
  77.                 Thread.Sleep(rest);
  78.                 myport.RtsEnable = true;
  79.                 Thread.Sleep(dit);
  80.                 myport.RtsEnable = false;
  81.                 Thread.Sleep(dah2);
  82.                 myport.Close();
  83.             }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top