Jump to content

Arduino to Autoit serial communication


Recommended Posts

Hi all, I am trying to let my arduino communicate with autoit for a musical project (a hardware interface for software loop stations like Mobius). My goal is to send autoit some data over serial and then have autoit emulate keyboard presses.

I am using CommMG library because I could find the easiest codes for that (I am not a coder in real life).

Here is a link to the reference topic i got inspired from: 

 

This is the autoit code:

#include <CommMG.au3>
    Global $CMPort = 3
Global $CmBoBaud = 9600
Global $sportSetError = ''
Global $CmboDataBits = 8
Global $CmBoParity = "none"
Global $CmBoStop = 1
Global $setflow = 2
    _CommSetPort($CMPort, $sportSetError, $CmBoBaud, $CmboDataBits, $CmBoParity, $CmBoStop, $setflow)
    If @error Then
    MsgBox(16, "Error!", "Can't connect to Arduino on port - " & $CMPort)
    Exit
EndIf
    _CommSetRTS(0)
_CommSetDTR(0)
    While 1
    receive()
    Sleep(100)
WEnd
    Func receive()
    Local $ret = _CommGetLine(@CR, 100, 100) ; Waits for up to 100 for a carriage return response from Arduino.
    ConsoleWrite($ret & @CRLF) ;Print to Console.
EndFunc

As soon as i run the script, I get the "Error!", "Can't connect to Arduino on port - 3" message. Arduino is on COM 3 (at least this is what arduino IDE tells me).

Here is the arduino code

int a=0;
    void setup(){
    Serial.begin(9600);
    }
    void loop(){
    a++;
    Serial.print(a);
    delay(3000);
    }

Any idea about the cause? Why they are not connecting to each other?

Thanks!!

 

Edited by Baritonomarchetto
Link to comment
Share on other sites

  • 1 year later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

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