DIY Touch Screen Control Arduino in C#

A place to showcase LattePanda creations!
Post Reply
User avatar
Kellman616
Posts: 42
Joined: Fri Feb 24, 2017 7:11 am

Fri May 11, 2018 3:43 am

Since touchscreen has been used widely, we can play computer easily without keyboard and mouse. I want to make the best use of the touchscreen and my LattePanda (A SBC with Win10 system) to realize a new way of interaction. (Maybe this is the world first demo to control the Arduino GPIO with touchscreen gesture :shock: )


Download the Demo package here:
DEMO folder.rar
(92.22 KiB) Downloaded 394 times
Note: Upload StandardFirmata to your Arduino Leonardo before you run the demo :idea:
(How to Upload StandardFirmata? Click here)



A LattePanda is a complete Windows 10 single board computer. It's much more powerful than Repberry Pi. $89 SBC can run Win10 with no lags. And run Ubuntu. Any peripherals that work on your PC will work on a LattePanda. It 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!


What you need:

Hardware:
Software

Demo 1: Detect Mouse position and click event

Let's do the project step by step. First thing of all, try to detect if the mouse is pressed or not. So we can detect the double click and triple click according to the interval.

It's a simple Windows Form Application. The textbox will show you the X axis and Y axis of the mouse. You can play this demo on your PC.

Image
DEMO folder.rar
(92.22 KiB) Downloaded 394 times
How to play Demo 1:

Run the .exe and move your mouse, the software will automatically detect the position of the mouse. If you press the left button of the mouse, the textbox will show the event.
You can see the code in the attachments or download the demo here. If you want to DIY this demo, you need to download Visual Studio here. Open.sln file and then you can make it your own.

If you have any questions, please let me know!


Demo 2: Detect Double-Click and control the LED

In this demo, you will know how to detect the double-click (Just calculate the interval of two clicks) and control the LED by Arduino Leonardo.

This demo involved C# and Arduino serial communication (communication between PC and Arduino).If you want to know this part of knowledge, see the tutorial here.

Image

See the picture above. To prevent a wrong trigger, I set the 1/5 of the screen area to detect the double-click of the mouse.

Image
DEMO folder.rar
(92.22 KiB) Downloaded 394 times
How to play DEMO 2:

Double-Click on the right 1/5 side of the screen, then you will enter the GPIO control mode, the LED will be turned on. Click on the left 4/5 side of the screen, the LED will be turned off.
You can see the code in the attachments or download the demo here. If you minimize the window, the function still working. It's cool, isn't it?

It's a new method to do a interaction project. It can also used in home automation control system. Use your PC to control the air-conditioner, light, TV, etc.


Demo 3: Detect Triple-Click and control the Screen background light

In this demo, you will get the position of your mouse and send the real-time value to your PC. Then your PC can change the background light according to the value. You can also play this demo on your PC.

This demo involved use C# to control the background light of the screen. If you want to know this part of knowledge, you can see the tutorial here.

Image
DEMO folder.rar
(92.22 KiB) Downloaded 394 times
How to play DEMO 3:

Triple-click on the right 1/5 side of the screen, then you will enter the GPIO control mode, move your finger up or down, the background light of your screen will turn ligher or darker.
This function is a little similar to the one of your iPhone. You can see the code in the attachments or download the demo here.

Have fun!

So far so good? If you have any questions, please let me know!


Demo 4: Detect Triple-Click and control the LED light

In this demo, you will get the position of your mouse and send the real-time value to your Arduino. Then your Arduino can control the LED according to the value.

This demo involved communication between PC and Arduino (Arduino and C# communication). If you want to know this part of knowledge, see the tutorial here.

Image
DEMO folder.rar
(92.22 KiB) Downloaded 394 times
How to play DEMO 4:

Triple-click on the right 1/5 side of the screen, then you will enter the GPIO control mode, move your finger up or down, the LED(D13) will turn ligher or darker.
You can see the code in the attachments or download the demo here. If you have any questions, please let me know!


Summary:

You get what you pay! I can't endure the lag when I run Win10 on Respberry Pi. LattePanda is a nice choice for you when you need to do a big project on SBC and it's x64 based processor. The CPU of LattePanda can perfectly handle big projects. It can also run Ubuntu perfectly. For me, LattePanda is a good platform to train my coding ability. Since it run Win10 system, I can use Visual Studio to do many projects in C++, C#, Python and so on. More importantly, it also has Arduino Leonardo on the board. I can easily control the physical world on my PC.

User avatar
LattePanda
Site Admin
Posts: 2472
Joined: Wed Jan 20, 2016 9:09 am

Fri May 18, 2018 3:31 am

Nice ;)
Enjoy Tinkering with LattePanda ! :lol:

Post Reply