Hello:
I'm a beginner of labview and I'm working on a project now. In this project I need to input a variable to labview, and this variable will be sent to arduino through VISA serial port. Then a servo motor connected to arduino will rotate a degree based on this variable. When I disconnect the motor, the VISA can work and I can see input variable on LCD (RX, RT LED keep ligiting). But when I execute the command "myservo.write()" in arduino, the VISA stop working. Nothing displayed on LCD and motor cannot rotate. If I stop the labview program, the labview will report error. So how can I fix this problem and let moror rotate? waiting for solution, Thanks.
Arduino code:
void setup()
{
// Initialize Serial Port With The Default Baud Rate
syncLV();
// Place your custom setup code here
myservo1.attach(6);
Serial.begin(9600);
lcd.begin(16, 2);
lcd.clear();
myservo1.write(0);
}
/*********************************************************************************
** loop()
**
** The main loop. This loop runs continuously on the Arduino. It
** receives and processes serial commands from LabVIEW.
**
** Input: None
** Output: None
*********************************************************************************/
void loop()
{
// Check for commands from LabVIEW and process them.
checkForCommand();
// Place your custom loop code here (this may slow down communication with LabVIEW)
myservo1.write(0);
lcd.clear();
lcd.setCursor(0, 1);
lcd.clear();
inc = "";
while(Serial.available() > 0)
{
income = ((byte)Serial.read());
inc += income;
}
lcd.print(inc);
//delay(50);
unitX =(int)inc[2] - 48;
tenX = (int)inc[1] - 48;
hundredX = (int)inc[0] - 48;
positionX = 100 * hundredX + tenX * 10; + unitX;
lcd.setCursor(0, 1);
angle1 = positionX - 74;
lcd.print(positionX);
delay(100);
myservo1.write(angle1);
positionX = 0;
}