LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to program a photoelctric sensor?

Solved!
Go to solution

Hello !

I am trying to make a little project and i just bought a arduino board UNO R3 and a photoelectric sensor. I tried to make a program for the sensor but it didnt work out and i cant find the problem… Can anyone help me, please? 

image.jpg

image.jpg

0 Kudos
Message 1 of 9
(1,165 Views)

@Bianca-Alexandra wrote:

Hello !

I am trying to make a little project and i just bought a arduino board UNO R3 and a photoelectric sensor. I tried to make a program for the sensor but it didnt work out and i cant find the problem… Can anyone help me, please? 

 

 


Hello and welcome, best bet for getting help is to post your code, that way everyone can read and understand what is going on. Also be explicit on what you are trying to do and what did not work. If you do that we can have you up and running in no time.

______________________________________________________________
Have a pleasant day and be sure to learn Python for success and prosperity.
Message 2 of 9
(1,120 Views)

How have you connected your photo sensor?

 

Typically, you create a potential divider with the photo sensor and a resistor, connect the junction to analog input of Arduino, and then use the Read Analog function of LINX to get the analog voltage.

Santhosh
Soliton Technologies

New to the forum? Please read community guidelines and how to ask smart questions

Only two ways to appreciate someone who spent their free time to reply/answer your question - give them Kudos or mark their reply as the answer/solution.

Finding it hard to source NI hardware? Try NI Trading Post
Message 3 of 9
(1,117 Views)

Hello!

Well i didn’t knew that i need also a resistor…

My connection looks like this, and this is my program 

You say that instead i should move to Analog the black wire and do this also in program? There is a chance of doing the program without the resistor?

Download All
0 Kudos
Message 4 of 9
(1,073 Views)

BiancaAlexandra_0-1677143234769.png

BiancaAlexandra_1-1677143456594.png

 

so this is the code in lab view and all i did on the arduino board was to connect the brown wire to 5V, the blue to GND and the black one to Digital 7 . And i tried to upload the code  but nothing happened... 

0 Kudos
Message 5 of 9
(1,066 Views)

Ohh,  what im trying to do is just to test it for now cause i have a big project to do until end of june ... I just want to understand how is working and until now is not a succes for me 

0 Kudos
Message 6 of 9
(1,064 Views)

better picture of the code 

BiancaAlexandra_0-1677143693850.png

 

thx 😘

0 Kudos
Message 7 of 9
(1,062 Views)

Hi Bianca,

 


@Bianca-Alexandra wrote:

My connection looks like this, and this is my program


You still don't provide a lot of information…


@Bianca-Alexandra wrote:

all i did on the arduino board was to connect the brown wire to 5V, the blue to GND and the black one to Digital 7 .


This information is nonsense! How should we know what the colors actually mean?

Which sensor do you use? Mind to share specs/part numbers?

 


@Bianca-Alexandra wrote:

better picture of the code


You didn't attach "your program", but you attached "an image of the block diagram of your VI": we cannot edit/debug/run images in LabVIEW!

(You also don't care about using AutoCleanup…)

 

Btw. do you know you can edit your message (within a short period of time) instead of posting 4 messages in a row?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 8 of 9
(1,060 Views)
Solution
Accepted by topic author Bianca-Alexandra

What's worse than a picture of code, is a picture of a screen with the code...

 

I have no experience with LINX, but by quick reading the documentation here are some possible solutions:

- Digital Read function requires you to Set Digital Pin Mode first (according to this)

- Did you load the LINX Firmware to the Arduino?

- As santo_13 pointed out, make sure that you have the sensor connected correctly (and that the sensor actually works)

- Are you sure you need digital read for this? This kind of sensors usually output analog values, so the better choice would be Analog Read function (and connect it to the appropriate pins on Arduino)

Message 9 of 9
(1,044 Views)