Hallo Leute,
ich probiere gerade die Kommunikation zwischen Arduino und AutoIT aus.
Bis jetzt hab ich erfolgreich über einen Poti einen und auch zwei Servos steuern können.
Jetzt möchte ich aber den Versuch wagen die Servos über AutoIt zu steuern, leider
komme ich gerade nicht weiter und bitte um eure Hilfe, vielleicht hat von euch schon jemand so was programmiert.
Für alle Vorschläge bin ich dankbar.
MfG dr-dado
Hier der Code den ich aus Arduino verwendet habe
// Controlling a servo position using a potentiometer (variable resistor)
// by Michal Rinott <http://people.interaction-ivrea.it/m.rinott>
#include <Servo.h>
Servo myservo; // create servo object to control a servo
int potpin = 0; // analog pin used to connect the potentiometer
int val; // variable to read the value from the analog pin
void setup()
{
myservo.attach(9); // attaches the servo on pin 9 to the servo object
}
void loop()
{
val = analogRead(potpin); // reads the value of the potentiometer (value between 0 and 1023)
val = map(val, 0, 1023, 0, 179); // scale it to use it with the servo (value between 0 and 180)
myservo.write(val); // sets the servo position according to the scaled value
delay(15); // waits for the servo to get there
}
Hier mein Code aus AutoIT
#include <CommMG.au3>
#include <GUIConstantsEx.au3>
#include <SliderConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
$GUI = GUICreate("Slider test")
$slider = GuiCtrlCreateSlider (0,0,200,20)
GUICtrlSetLimit ($slider,100,0)
$label = GUIctrlcreatelabel("",30,100,70,20)
GUISetState()
$procent = 100
Global $sportSetError = ''
Global $CmPort = 6
Global $CmBoBaud = 9600
Global $CmboDataBits = 8
Global $CmBoParity = "none"
Global $CmBoStop = 1
Global $setflow = 2
_CommSetPort($CmPort, $sportSetError, $CmBoBaud, $CmboDataBits, $CmBoParity, $CmBoStop, $setflow)
While 1
Sleep(10)
$procent = GuictrlRead($slider)
GUICtrlsetdata($label,"Slider= "&$procent&"%" )
_CommSendstring($procent)
wend