LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

control LEDs with a potentiometer via LabVIEW and Arduino

Solved!
Go to solution

Good morning,

I'm currently working on a project with LabVIEW and Arduino, and I need help implementing a specific feature. My goal is to read the value of a potentiometer plugged into Arduino using LabVIEW and then light up different LEDs based on that value.

More specifically, here is what I want to achieve:

Read the value of the potentiometer connected to Arduino from LabVIEW.
If the value read is greater than or equal to 3, turn on an LED connected to pin 7 of the Arduino.
Otherwise, if the value is less than 3, turn on another LED connected to pin 8 of the Arduino.
Being a beginner, I am asking for your advice and suggestions to improve the structure of my code, in particular by using the LabVIEW case structure effectively.

I thank you in advance for any help you can give me.

0 Kudos
Message 1 of 8
(723 Views)

Bonjour,

Je travaille actuellement sur un projet avec LabVIEW et Arduino et j'ai besoin d'aide pour implémenter une fonctionnalité spécifique. Mon objectif est de lire la valeur d'un potentiomètre branché sur Arduino à l'aide de LabVIEW, puis d'allumer différentes LED en fonction de cette valeur.

Plus précisément, voici ce que je souhaite réaliser :

Lisez la valeur du potentiomètre connecté à Arduino depuis LabVIEW.
Si la valeur est supérieure ou égale à 3, allumez une LED connectée à la broche 7 de l'Arduino.
Sinon, si la valeur est inférieure à 3, allumez une autre LED connectée à la broche 8 de l'Arduino.
Etant débutant, je sollicite vos conseils et suggestions pour améliorer la structure de mon code, notamment en utilisant efficacement la structure conditionnelle (structure de cas) de LabVIEW.

Je vous remercie d'avance pour toute l'aide que vous pourrez m'apporter.

0 Kudos
Message 2 of 8
(728 Views)
Solution
Accepted by topic author angeline1

Hi Angeline,

 


@angeline1 wrote:Read the value of the potentiometer connected to Arduino from LabVIEW.

If the value read is greater than or equal to 3, turn on an LED connected to pin 7 of the Arduino.
Otherwise, if the value is less than 3, turn on another LED connected to pin 8 of the Arduino.
Being a beginner, I am asking for your advice and suggestions to improve the structure of my code, in particular by using the LabVIEW case structure effectively.

 


You only switch pin 7 inside the case structure, but you don't switch pin 8 in your VI.

And it seems you don't switch off pin7/8 when the condition is NOT matched…

 

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 3 of 8
(677 Views)

First of all, I would like to thank you for your attention to my request.

I noticed that my program works efficiently as long as the threshold is lower than 3. It manages to acquire the signal from the potentiometer without any problem. However, as soon as the signal becomes greater than 3, a malfunction occurs and an error message is displayed.

After looking at the code, I suspect there is an error within the control structure (case/switch). Unfortunately, I have not yet managed to correct it, being still in the training phase.

I would be grateful if you could help me resolve this situation. Any suggestions or advice would be greatly appreciated.

test.png

Capture d’écran 2024-03-30 223916.png

  

0 Kudos
Message 4 of 8
(661 Views)

First of all, I would like to thank you for your attention to my request.

I noticed that my program works efficiently as long as the threshold is lower than 3. It manages to acquire the signal from the potentiometer without any problem. However, as soon as the signal becomes greater than 3, a malfunction occurs and an error message is displayed.

After looking at the code, I suspect there is an error within the control structure (case/switch). Unfortunately, I have not yet managed to correct it, being still in the training phase.

I would be grateful if you could help me resolve this situation. Any suggestions or advice would be greatly appreciated.

Capture d’écran 2024-03-30 223916.png

test.png

  

0 Kudos
Message 5 of 8
(660 Views)

Hi angeline,

 

the error message is quite clear: your hardware doesn't support the requested feature! (Or the LINX software doesn't support your hardware with all its features.)

 

There is no problem with the case structure in LabVIEW.

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 6 of 8
(629 Views)
Solution
Accepted by topic author angeline1

if the code is still like the fist message, then your  are missing a wire inside the case structure to indicate the LInx device. 

 

 

LVNinja_2-1711980775450.png

 

 

 

Message 7 of 8
(611 Views)

 Hi,

It worked, thank you. I just forgot to connect the wire, thanks for your help.

0 Kudos
Message 8 of 8
(597 Views)