Introduction: Winforms+Lattepanda=Control Everything With Your Mouse!

Today, I will try to use Winforms to build a window that can control the LED lights. Originally, we need a laptop and Arduino to realize this function.But now, we have Lattepanda!


What is Lattepanda?

A LattePanda is a complete Windows 10 single board computer. It has everything a regular PC has and can do anything that a regular PC does. It is compatible with almost every gadget you know: printers, joysticks, cameras and more. Any peripherals that work on your PC will work on a LattePanda.

A LattePanda also includes an integrated Arduino compatible co-processor, using hundreds of mature development platforms such as Johnny Five and Cylon, you can easily used it to control and sense the physical world! Whether you are a Windows developer, IoT developer, DIY fanatic, interactive designer, robotics whizz, or maker, a LattePanda single board computercan aid your creative process!

Step 1: Hardware List

  • Lattepanda
  • HDMI label
  • Mouse
  • Keyboard

Step 2: Software Setup

Step 3: C# Code

Creat a new windows Form project. Drag out 2 button components from toolbox.Rename them,one is 'ON', one is 'OFF'.

public partial class Form1 : Form
{ SerialPort port;

public Form1() { InitializeComponent();

this.FormClosed += new FormClosedEventHandler(Form1_FormClosed);

if (port == null) { //Change the portname according to your computer port = new SerialPort("COM4", 9600); port.Open(); } }

void Form1_FormClosed(object sender, FormClosedEventArgs e)
{ if (port != null && port.IsOpen) { port.Close(); } }

private void button1_Click(object sender, EventArgs e)
{ PortWrite("1"); }

private void button2_Click(object sender, EventArgs e) { PortWrite("0"); }

private void PortWrite(string message)
{ if (port != null && port.IsOpen) { port.Write(message); } } }


Step 4: Arduino Sketch

const int LedPin = 3;
int ledState = 0;

void setup() { pinMode(LedPin, OUTPUT); Serial.begin(9600); }

void loop() { char receiveVal; if(Serial.available() > 0) { receiveVal = Serial.read(); if(receiveVal == '1') ledState = 1; else ledState = 0; } digitalWrite(LedPin, ledState); delay(50); }

Step 5: Result

When you click the 'ON' button the LED light will turn on.

If you other things instead of the LED, then you can use your mouse to control everything!!

That's a very useful function, so I post this tutorial to show you how to do that.

Hope this tutorial is useful for you!

Enjoy:-)

Comments

About This Instructable

137views

5favorites

Bio: Green hand in arduino
More by 375668457:LattePanda Face RecognizeCommuncation: LattePanda⇌LeonardoControl the Stepper Motor With Bluetooth
Add instructable to: