med5801
❔ Need Help
using System;
using System.Diagnostics;
using System.IO.Ports;
namespace ABRA_KEYBOARD_CTRL
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Press ESC to stop");
SerialPort port = new SerialPort("COM5", 115200);
port.DataBits = 8;
port.StopBits = StopBits.One;
port.Handshake = Handshake.None;
port.Parity = Parity.None;
port.Open();
port.Write("#Keyboard App Started#");
do {
while (!Console.KeyAvailable) ;
{
switch (Console.ReadKey(true).Key)
{
default:
Console.WriteLine("ERR!");
break;
case ConsoleKey.W:
Console.WriteLine("KeyPressed: W");
port.Write("1");
break;
case ConsoleKey.D:
Console.WriteLine("KeyPressed: D");
port.Write("D");
break;
case ConsoleKey.UpArrow:
Console.WriteLine("KeyPressed: up");
port.Write("3");
break;
case ConsoleKey.Escape:
port.Close();
Environment.Exit(0);
break;
}
}
}
while (Console.ReadKey(true).Key != ConsoleKey.Escape);
Process.GetCurrentProcess().WaitForExit();
}
}
}
using System;
using System.Diagnostics;
using System.IO.Ports;
namespace ABRA_KEYBOARD_CTRL
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Press ESC to stop");
SerialPort port = new SerialPort("COM5", 115200);
port.DataBits = 8;
port.StopBits = StopBits.One;
port.Handshake = Handshake.None;
port.Parity = Parity.None;
port.Open();
port.Write("#Keyboard App Started#");
do {
while (!Console.KeyAvailable) ;
{
switch (Console.ReadKey(true).Key)
{
default:
Console.WriteLine("ERR!");
break;
case ConsoleKey.W:
Console.WriteLine("KeyPressed: W");
port.Write("1");
break;
case ConsoleKey.D:
Console.WriteLine("KeyPressed: D");
port.Write("D");
break;
case ConsoleKey.UpArrow:
Console.WriteLine("KeyPressed: up");
port.Write("3");
break;
case ConsoleKey.Escape:
port.Close();
Environment.Exit(0);
break;
}
}
}
while (Console.ReadKey(true).Key != ConsoleKey.Escape);
Process.GetCurrentProcess().WaitForExit();
}
}
}
34 replies
what is the easiest way to make a prime number finder
using System;
using System.Threading;
namespace asal_sayı_bulucu
{
class Program
{
static void Main(string[] args)
{
int a = 0;
int sayi = 2;
while (sayi<1000)
{
for (int i = 1; i < sayi; i++)
{
if (sayi % i == 0)
{
a++;
}
}
if (a==1)
{
Console.WriteLine(sayi);
sayi++;
}
else
{
sayi++;
}
a = 0;
Thread.Sleep(1);
}
}
}
}
using System;
using System.Threading;
namespace asal_sayı_bulucu
{
class Program
{
static void Main(string[] args)
{
int a = 0;
int sayi = 2;
while (sayi<1000)
{
for (int i = 1; i < sayi; i++)
{
if (sayi % i == 0)
{
a++;
}
}
if (a==1)
{
Console.WriteLine(sayi);
sayi++;
}
else
{
sayi++;
}
a = 0;
Thread.Sleep(1);
}
}
}
}
1 replies