04-16-2024 01:18 PM
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
}
}
04-17-2024 09:37 AM - edited 04-17-2024 09:55 AM
In general there are three ways of using LabVIEW with an Arduino
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.