Created
August 12, 2017 23:41
-
-
Save CristianoRC/70fe9d059898171e9c1c0e11d7e656a7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.IO.Ports; | |
using System.Diagnostics; | |
namespace ComunicacaoArduino | |
{ | |
class MainClass | |
{ | |
public static void Main(string[] args) | |
{ | |
var portas = SerialPort.GetPortNames(); | |
foreach (var item in portas) | |
{ | |
Console.WriteLine($"Porta - {item}"); | |
} | |
Console.WriteLine("\n----------\n\n"); | |
using (SerialPort comunicacao = new SerialPort("/dev/ttyACM0", 9600)) | |
{ | |
comunicacao.Open(); | |
Console.WriteLine(comunicacao.ReadLine() + "\n\n-----\n\n"); | |
var manusearLED = true; | |
while (manusearLED) | |
{ | |
Console.Clear(); | |
Console.Write("\nDigite 'L' para ligar e 'D' para desligar:"); | |
var resultado = Console.ReadLine(); | |
comunicacao.Write(resultado.ToUpper()); | |
Console.WriteLine(comunicacao.ReadLine()); | |
Console.WriteLine("\n\nDesenha sair (S/N): "); | |
var resultadoSair = Console.ReadLine(); | |
if (resultadoSair == "S") | |
manusearLED = false; | |
} | |
comunicacao.Close(); | |
} | |
Console.ReadKey(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment