LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Arduino Digital Pin read in Labview

Hi all,

 

I am using an Arduino Mega 2560 board. In which I want to connect an external voltage 4v to any digital pin of it and when that pin get high I want to get any other digital pin set to boolean true. Would be great if anyone could help to write it in the Labview.

------------------Arduino code--------------------

const int externalSignalPin = 22; // external signal is connected to digital pin 22 of 4 volt
const int outputPin = 24; // want to set digital pin 13 to HIGH when the signal is detected

void setup() {
pinMode(externalSignalPin, INPUT);
pinMode(outputPin, OUTPUT);
}

void loop() {
// Reading the voltage on the external signal pin
int signalValue = digitalRead(externalSignalPin);

if (signalValue == HIGH) {
digitalWrite(outputPin, HIGH); // Set the output pin to HIGH
} else {
digitalWrite(outputPin, LOW); // Set the output pin to LOW
}
}

 

0 Kudos
Message 1 of 2
(356 Views)

In general there are three ways of using LabVIEW with an Arduino

 

  1. Program the Arduino in the native Arduino language.
    1. LabVIEW can communicate with an Arduino using VISA just like any other instrument on a serial port.
    2. IMHO: this is the best way as you have full control over the communications protocol and access to all of the of Arduino libraries and LabVIEW toolkits that are already out there.
    3. I highly recommend watching this video on serial communications: VIWeek 2020/Proper way to communicate over serial
  2. Use LINX (Now called the Hobbyist Toolkit) 
    1. Full LabVIEW integration, but limited amount of Arduino libraries and peripherals directly supported
    2. The Arduino basically becomes a tethered DAQ device that needs to be connected to a computer/LabVIEW to work
  3. TSXperts Arduino compiler for LabVIEW
    1. Actually turns LabVIEW into stand alone Arduino code. (A real feat on its own)
      1. Limited subset of LabVIEW vi's and primitives
      2. Very limited support for Arduino libraries 
      3. Development has stopped, so those annoying bugs are here to stay

That being said... It sounds like you are using digital input to read an analog voltage? I am not sure that is going to work reliably since it's a digital input. Four volts is probably outside of the "gray area" for an Arduino digital input (assuming 5 volt logic), but who knows exactly what input voltage constitutes a "high" or "low"? I am sure there's a range that is mostly guaranteed, but honestly you should be using an analog input if you need to measure an analog voltage and set a digital output when the input is greater than a certain level.  

 

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 2 of 2
(302 Views)