Create a gist now

Instantly share code, notes, and snippets.

@Ekus /EkusTV.aspx
Last active Apr 21, 2018

What would you like to do?
An ASP.NET page that controls Arduino using USB to Serial connection. I use it to have the Arduino send an IR signal that turns my TV on/off. I use Amazon Echo to send a GET request to this page when I say "Alexa, turn on/off the TV"
<%@ Page Language="C#" AutoEventWireup="true" %>
<%@Import Namespace="System.IO.Ports" %>
<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
using (SerialPort sp = new System.IO.Ports.SerialPort())
{
sp.PortName = "COM3";
sp.BaudRate = 9600;
sp.Open();
sp.Write("1");
System.Threading.Thread.Sleep(100);
sp.Write("1");
sp.Close();
}
}
</script>
<html>
<body>
<h1>HI</h1>
<%=System.DateTime.Now %>
</body>
</html>
@DIWAKER089

This comment has been minimized.

Show comment Hide comment
@DIWAKER089

DIWAKER089 Apr 2, 2018

<%@ Page Language="C#" AutoEventWireup="true" %>
<%@import Namespace="System.IO.Ports" %>

<script runat="server"> protected void Page_Load(object sender, EventArgs e) { SerialPort sp = new System.IO.Ports.SerialPort(); sp.PortName = "COM3"; sp.BaudRate = 9600; sp.Open(); sp.Write("1"); System.Threading.Thread.Sleep(100); sp.Write("1"); // repeat, just in case. That's not the best way to do it but I didn't have time to investigate Samsung IR codes more. It's good enough. sp.Close(); } </script>

HI

<%=System.DateTime.Now %>

<%@ Page Language="C#" AutoEventWireup="true" %>
<%@import Namespace="System.IO.Ports" %>

<script runat="server"> protected void Page_Load(object sender, EventArgs e) { SerialPort sp = new System.IO.Ports.SerialPort(); sp.PortName = "COM3"; sp.BaudRate = 9600; sp.Open(); sp.Write("1"); System.Threading.Thread.Sleep(100); sp.Write("1"); // repeat, just in case. That's not the best way to do it but I didn't have time to investigate Samsung IR codes more. It's good enough. sp.Close(); } </script>

HI

<%=System.DateTime.Now %>
@DIWAKER089

This comment has been minimized.

Show comment Hide comment
@DIWAKER089

DIWAKER089 Apr 2, 2018

hjgjygh

hjgjygh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment