Jump to content

Arduino functions for autoit


xapu
 Share

Recommended Posts

hi!

i made the basic native arduino functions in autoit to control it trougth the serial port.

it could be interesting for too many people

you can find the codes here

in my blog there are some more codes using arduino and autoit too

xapus.blogspot.com

Edited by xapu
Link to comment
Share on other sites

My UDF: NetInfo UDF Play with your network, check your download/upload speed and much more! YTAPI Easy to use YouTube API, now you can easy retrive all needed info from a video. NavInfo Check if a specific browser is installed and retrive other usefull information. YWeather Easy to use Yahoo Weather API, now you can easily retrive details about the weather in a specific region. No-IP UDF Easily update your no-ip hostname(s).

My Script: Wallpaper Changer Change you wallpaper dinamically, you can also download your wallpaper from your website and share it with all!   My Snippet: _ImageSaveToBMPConvert an image to bmp format. _SciteGOTO Open a file in SciTE at specific fileline. _FileToHex Show the hex code of a specified file

Link to comment
Share on other sites

it return an error message : can't perform this operation on a closed port, port = none, channel number = 1  :mellow:

have you selected the rigth port where your arduino is connected?

Link to comment
Share on other sites

  • 2 years later...

Ok i know this thread is a bit old, 2013 to be exact but am hoping that one can direct me as to what i am doing wrong.

I followed the link above, downloaded the file, put the arduino.au3 and comm files in the include folder of autoit.

I then went and opened the arduino file in the associated software and loaded it onto the arduino.

I opened the first file in autoit, blink, and changed the com port from 3 to 4 since my USB is on 4

Ran the file, nothing happened

the only thing that happened was in the console of autoit i received the number 02

Other than that nothing.

So what step did i miss?

Link to comment
Share on other sites

Try this code (I Use this to communicate with arduino):

unplug all the coms connected to your computer only arduino to it

Upload the sketch to arduino run the Arrduino Serial.au3 and click Connect

if it says connected then type in "motor on" in the first edit box then click send connect a motor to 8th pin of arduino if its rotating voilla!! you have succeded in connecting your board to autoit

 

 

Serial communication.zip

No matter whatever the challenge maybe control on the outcome its on you its always have been.

MY UDF: Transpond UDF (Sent vriables to Programs) , Utter UDF (Speech Recognition)

Link to comment
Share on other sites

Hi,

Surya, i (and i think mrtweaver too) have no problems to interact with the Arduino-sketch (the sketch! ) via serial connection.

There is a difference to send and read "serial" bytes between Arduino-sketch and AutoIt  and the possibility to read or write digital or analog in/out-Pins from the Arduino via digitalread()/digitalsend()/analogread()/analogsend()-AutoIt-Functions.

I tried to load an "empty" Sketch into Arduino to force it to "do nothing". After that i connected AutoIt (like the communication-Scetch) to Arduino and tried a digitalwrite(10,1) to light the LED (i use this LED mostly for debugging^^ )//EDIT The LED did not light up!

How can i read/write analog/digital pin-states from Arduino with AutoIt "directly"? For sure i could write a sketch which reads the state of an Arduino-port and send this as a string "Hi this is Arduino, Digital Port 4 is ON" to AutoIt. That´s not the problem! I would like to use the AutoIt-function digitalread(4) to receive "ON"

Edited by AndyG
Link to comment
Share on other sites

Hi andyg i understood you,  i have tried out the digitalwrite function provided in arduino. Au3 it dont work for me i think that you should use arduino. Exe's command line parameter to upload an arduino scheme written in autoit i don't think arduino board accepts single command execution (i am not sure)

No matter whatever the challenge maybe control on the outcome its on you its always have been.

MY UDF: Transpond UDF (Sent vriables to Programs) , Utter UDF (Speech Recognition)

Link to comment
Share on other sites

i think this will do the task:  (CODE UNTESTED)

#include <File.au3>

Func digitalWrite($pin, $com = "COM36",$mode = "LOW",$inst = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Arduino","Install_Dir") &"\arduino.exe" );$mode can only be LOW / HIGH
    $file = _TempFile(@TempDir, "~", ".ino")
    FileWrite($file,_SourceCode(9,"digitalWrite"))
    $run = $inst &" --upload --board arduino:avr:pro --port " &$com &" --verbose-upload " &$file
    $exit = RunWait($run,"",@SW_HIDE)
    Return $exit
EndFunc   ;==>DigitalWrite


Func _SourceCode($pin,$do,$state = "HIGH",$out = "OUTPUT")
     $src = "void setup() {" & _
            @CRLF &"pinMode(" &$pin &", " &$out &");" & _
            @CRLF &"}" &@CRLF  & _
            @CRLF &"void loop() {" & _
            @CRLF &$do &"(" &$pin &"," &$state &")" & _
            @CRLF &"}"
            Return $src
EndFunc   ;==>_SourceCode

 

Edited by Surya

No matter whatever the challenge maybe control on the outcome its on you its always have been.

MY UDF: Transpond UDF (Sent vriables to Programs) , Utter UDF (Speech Recognition)

Link to comment
Share on other sites

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

×
×
  • Create New...