Quantcast
Channel: LabVIEW topics
Viewing all articles
Browse latest Browse all 68930

Labview/Arduino bluetooth connection

$
0
0

Hi everyone !

I have to pilot a DC motor with an arduino, and to set the duty cycle with labview 2016. The communication MUST be by bluetooth. The bluetooth æodule is a HC-06. Then, I will use a sensor connected to the arduino, and send back the datas to labview.

Blocs.pngThe problem is that I had never use labview before. For now, I can't exchange datas with the arduino.

The code is very simple :

 

String fromArduino;

void setup() {
  pinMode(5,OUTPUT);
  Serial.begin(9600);
}

void loop() {
  if(Serial.available()){
    fromArduino = Serial.readString();
    analogWrite(5,fromArduino.toInt());
    Serial.println(fromArduino);
  }
}

There isn't any problem with it, it works well while using the serial monitor of arduino IDE, and I can control the duty cycle by bluetooth using a selfmade android app. (and the hardware is working well)

 

So I tried to use linx (1) to control the arduino. It works using the usb connection, but not with bluetooth. Anyway, I probably need to use my own code on the arduino so linx isn't a good solution right ?

 

Then I used visa (2) but it doesn't work too. I selected the right com port, the bluetooth module was connected, but nothing happened. 

Here are some of the codes I made.

testsBTdiagrams1.jpgThen I tried to just set a digital output of the arduino by send 1 or 0 with labview but it's the same. The bluetooth module is connected, I send the datas by bluetooth, then nothing.

testBTdiagram2.pngAnand the code is :

int data;

void setup() {
  Serial.begin(9600); 
  pinMode(5,OUTPUT);
  pinMode(9,OUTPUT);
}

void loop() {
  if(Serial.available()){
    data=Serial.read();
    if (data==0){
      digitalWrite(5,LOW);
      digitalWrite(9,LOW);
    }
    if (data==1){
      digitalWrite(pin,HIGH);
      delay(500);
    }
    else digitalWrite(9,HIGH);  
    digitalWrite(5,LOW);  
  }
}

I am sure that it's not a big deal, but I can't figure out why it doesn't work. Can anybody help me ?

Cheers


Viewing all articles
Browse latest Browse all 68930

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>