Author Topic: An Astonishing Arduino Accomplishment  (Read 568 times)

After 7 loving hours of struggling with sockets, COM ports, and C++ in general, I've finally created what is quite possibly the most complicated and awesome way to communicate with an arduino ever devised.

I wanted to communicate with the arduino from my PC. I knew that I could do it in C++, but I loving hate C++ in all aspects except where speed is concerned. It's heavyweight, verbose, and writing code in it is like sawing off your own limbs with a hacksaw so you can win the special olympics. Instead, I devised a way to make C++ simply a middleman between the arduino and... wait for it... Lua.

Lua is loving great, and don't try to tell me otherwise. It may be slow but it's hands-down the easiest language I've ever encountered, for both learning and writing in. It's also extremely lightweight and portable, and if speed is not a factor, I will choose Lua over any other language every time, unless I need a specific library that I can't find for it.

That last exception is important, because I couldn't get any decent way to communicate with serial/COM ports using Lua without installing bulky and deadweight libraries that I'd have to compile myself. What I instead did was make a C++ program that would send and receive data from the Arduino, and send it via UDP to a Lua program, and vice-versa, with the Lua program sending data to the C++ program to be relayed to the Arduino. The benefits of this are that I get all of the communication functionality I need, being able to exchange bytes with the Arduino very easily, combined with the ease of writing tasks in Lua as opposed to C++. I was also able to integrate the UDP functionality into Love2D, which means that I can now communicate between my Love2D whatevers and my Arduino whatevers, in two directions.

In case you're wondering, the response time is about 32 milliseconds from Lua to Arduino and back again, or about 16ms each way, which is pretty impressive considering all of the exchanges the data goes through.

TL;DR: I made a thing that lets me talk to an Arduino from Lua.

Discuss arduino projects and accomplishments I guess, and congratulate me because I'm so smart.

Damn... people still using COM ports now and days.

Damn... people still using COM ports now and days.
Technically, it's a simulated COM port over USB.

cool

i played around with arduino for a bit once and it was p cool but i never did anything like this

i made a car once
but it exploded


congrats smarnty pats

Technically, it's a simulated COM port over USB.

I've heard of it, but never played with it before. However, just the fact that it emulates an outdated communication medium just repulses me.

I've heard of it, but never played with it before. However, just the fact that it emulates an outdated communication medium just repulses me.
u repuls me u silly willy nilly billy