Jump to content

Connected to the world


Recommended Posts

 

:thumbup:

 

I can't speak english very good.

 

Sorry for using the google translator.

 

I am creating a library "export.dll" for connecting the arduino directly to sim.

:joystick:

 

This is a beta, to test put the library in the bin folder of the sim. Export.rar is on attached file.

 

In the export.lua:

 

require("export") --load the library

 

opencom()-- open the serial port and configure it has 115200 bps.

example: opencom("COM7")

opencom() requires the Arduino will send the word "conected" at startup to continue. Serial.print("conected ");

See my arduino sketch.

 

writecom() -- send data to the serial port example: writecom("HelloWorld")

 

readcom() -- read the serial port example: print(readcom())

 

closecom() -- close the serial port

 

My export.lua example:

 

require("export") --load the library

 

function LuaExportStart()

opencom("COM7") --abrimos el puerto y esperamos a que el arduino envie el comando "conected"

end

 

function LuaExportBeforeNextFrame()

command = readcom() -- leemos datos del puerto serie y si corresponde con down o up le mandamos al sim que suba o baje el tren de aterrizaje.

if command == "down" then

LoSetCommand(431)

elseif command == "up" then

LoSetCommand(430)

end

end

 

function LuaExportAfterNextFrame()

local altBar = LoGetAltitudeAboveSeaLevel() --leemos la altura del sim

writecom(string.format("AltBar %2.fM.",altBar)) -- y la mandamos por el puerto serie

end[/center]

 

function LuaExportStop()

closecom() --cerramos el puerto serie

end

 

My arduino sketch:

 

#include <LiquidCrystal.h>

LiquidCrystal lcd(8, 9, 4, 5, 6, 7);

char caracter;

byte i=0;

char cadena[100];

int val = 0;

 

void setup()

{

Serial.begin(115200); //Configuramos puerto serie

lcd.begin(16, 2);

lcd.clear();

lcd.print("Arduino OK");

Serial.print("conected "); //Enviamos conected por el puerto serie

}

 

void loop()

{

if(Serial.available()) // si hay algo en el puerto serie lo imprimimos por pantalla

{

caracter=Serial.read();

if (caracter == 10)

{

cadena[i++]='';

i=0;

if(!strcmp(cadena,"state"))

{

lcd.clear();

lcd.setCursor(0, 0);

lcd.print("Conected to DCS");

}

else

{

lcd.clear();

lcd.setCursor(0, 0);

lcd.print(cadena);

}

 

}

else

cadena[i++]=caracter;

}

 

 

val = analogRead(0); //leemos los botones del arduinop y mandamos el comando por el puerto serie

 

if (val > 75 && val < 200)

{

Serial.print("up");

delay(200);

}

if (val > 200 && val < 350)

{

Serial.print("down");

delay(200);

}

 

}

 

:pilotfly:

export.rar


Edited by blackleg
Link to comment
Share on other sites

Nice! good job!

But format Text left side please :) its really hard to read!

 

It looks like you call a lot of functions that I don't see defined in this code nor referencing another file.

Just curious... are they all pre-defined in the syntax?

4790K@4,6Ghz | EVGA Z97 Classified | 32GB @ 2400Mhz | Titan X hydro copper| SSD 850 PRO

____________________________________

Moments in DCS:

--> https://www.youtube.com/user/weltensegLA

-->

 

WELD's cockpit: --> http://forums.eagle.ru/showthread.php?t=92274

Link to comment
Share on other sites

Nice! good job!

But format Text left side please :) its really hard to read!

 

It looks like you call a lot of functions that I don't see defined in this code nor referencing another file.

Just curious... are they all pre-defined in the syntax?

 

That functions?

Link to comment
Share on other sites

  • ED Team

great stuff

 

I am currently working on a ufc and caution panel using Arduino, I will keep an eye on this thread, very interesting stuff.

 

thanks for sharing

smallCATPILOT.PNG.04bbece1b27ff1b2c193b174ec410fc0.PNG

Forum rules - DCS Crashing? Try this first - Cleanup and Repair - Discord BIGNEWY#8703 - Youtube - Patch Status

Windows 11, NVIDIA MSI RTX 3090, Intel® i9-10900K 3.70GHz, 5.30GHz Turbo, Corsair Hydro Series H150i Pro, 64GB DDR @3200, ASUS ROG Strix Z490-F Gaming, HP Reverb G2

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...