Proximity sensors to switch on addressable LEDS in an epoxy table

Hi All,

Quick History:

I've built various epoxy resin items such as a stool and small table over the last few years, and for this years summer project I thought I would do the same but with some flashy LEDS embedded. After a quick trip through youtube and some craft forums I stumbled upon Arduino to control the LEDS. I have an IT back ground with some scripting and VBA programming thrown in. AKA: search on google for the answer and crowbar it in to what I want to to do :-), so I thought this would be fun.

As a way of controlling the leds I came across this example: Under this section: Interactive LED Coffee Table using the WS2812B LEDs

[https://howtomechatronics.com/tutorials/arduino/how-to-control-ws2812b-individually-addressable-leds-using-arduino/](https://How To Control WS2812B Individually Addressable LEDs using Arduino)

As this is a summer project I don't have any of the major items yet however I do have some small time to tinker with the code before the actual construction

Original code from the website:

#include "FastLED.h"

#define NUM_LEDS 45
#define LED_PIN 2
#define COLOR_ORDER GRB

CRGB leds[NUM_LEDS];

void setup() {
  FastLED.addLeds<WS2812, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS);
  FastLED.setBrightness(brightness);
  // Set the 45 proximity sensors pins as inputs, from digital pin 3 to pin 48
  for (int pinNo = 0 + 3; pinNo <= 45 + 3; pinNo++) {
    pinMode(pinNo, INPUT);
  }
}

void loop() {
  for (int pinNo = 0; pinNo <= NUM_LEDS-1; pinNo++) {
    leds[pinNo] = CRGB( 0, 255, 0);    // Set all 45 LEDs to green color 
    // If an object is detected on top of the particular sensor, turn on the particular led
    if ( digitalRead(pinNo + 3) == LOW ) {
      leds[pinNo] = CRGB( 0, 0, 255); // Set the reactive LED to bluee
    }
  }
  FastLED.show(); // Update the LEDs
  delay(20);
}

The example above just turns one (addressable) LED from Green to Blue if an item is placed/removed from the IR Proximity sensor.

I want to turn on multiple LEDS and have them fade on/off (just to white for the moment) when an item is placed/removed from the sensor. So I amended the above code.

My thoughts, and please feel free to correct, were to control the LEDS from a set of arrays rather than directly from the board input so I could have them fading out (rather then just turning off) when the proximity sensor is not longer activated.

I've created two arrays, one to hold the relative brightness of the LEDS and one to hold the time when the brightness was altered:

SENSOR_STATE[]
SENSOR_TIME[]

The relative brightness of the LEDS is set from the SENSOR_STATE array, depending on whether the sensor is on when the code will increase the value to 255 or down to 0 if the sensor is inactive.

The SENSOR_TIME array is used so that the SENSOR_STATE values are not increase/decreased to quickly. I'm am checking the last update time against the current time and only changing the value if this is greater the 0.02 of a second.

My idea was to have the first part of the loop fading out any LEDS that have been on. The main array SENSOR_STATE() by decrementing the relative brightness (255 down to 0) by 5 points every 0.02 of a second if the sensor is not active.

The second part increments the brightness by 5 points every 0.02 of second if the proximity sensor is enabled.

The loops should stop updating the leds array if the brightness count reaches 0 or 255 so those don't over run or if 0.02 seconds hasn't passed..

This code compiles on the Arduino site, which is a complete surprise!

I was wondering if some-one could take a look at the code and see if it will actually do as I would like it too and any other comments on any error conditions that might arise (I did note that millis() will over run after about 50 days) will be most welcome as this is my first foray into electronics since my degree over 25 years ago...

#include "FastLED.h"

#define NUM_LEDS 180
#define NUM_LEDS_ON 4
#define LED_PIN 2
#define COLOR_ORDER GRB
#define brightness 255
unsigned long myTime;
int SENSOR_STATE[45];
unsigned long SENSOR_TIME[45];

CRGB leds[NUM_LEDS];

void setup() {
  myTime = millis();
  FastLED.addLeds<WS2812, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS);
  FastLED.setBrightness(brightness);
  // Set the 45 proximity sensors pins as inputs, from digital pin 3 to pin 48, set the SENSOR State to 0 (OFF) and SENSOR Time to the current time
  for (int pinNo = 0 + 3; pinNo <= 45 + 3; pinNo++) {
    pinMode(pinNo, INPUT);
    SENSOR_STATE[pinNo] = 0;
    SENSOR_TIME[pinNo] = myTime;
  }

}


void loop() {

  // For statement to dim the all leds under these three conditions:
  // 1st condition: Sesnor state is above 5, As the sensor state is being used to control the brightness this can't go below 0
  // 2nd condition: Time delay for the incremental fade, 0.02 of a second
  // 3rd condition: Touch sensor not active

	for (int pinNo = 0; pinNo <= (NUM_LEDS/NUM_LEDS_ON)-1; pinNo++) {
    
    if ( (SENSOR_STATE[pinNo] >= '5') and (millis() > (SENSOR_TIME[pinNo] + 0.02)) and ( digitalRead(pinNo + 3) == HIGH ) ) {
    
        SENSOR_STATE[pinNo] = SENSOR_STATE[pinNo] - 5; 	// decrement the brightness
        SENSOR_TIME[pinNo] = millis(); 					// reset to current time 
    
  // loop to populate the required leds
  
        for ( int led_block = 0; led_block <= (NUM_LEDS_ON - 1)  ; led_block++ ){
          leds[(pinNo * NUM_LEDS_ON + led_block)] = CRGB( SENSOR_STATE[pinNo], SENSOR_STATE[pinNo], SENSOR_STATE[pinNo]);
        }
    }
  
  // For statement to increment all leds to a maximum brightness under these three conditions:
  // 1st condition: Sesnor state is below 255, As the sensor state is being used to control the brightness this can't go above 255
  // 2nd condition: Time delay for the incremental brightness increase, 0.02 of a second
  // 3rd condition: Touch sensor is active
  
    if ( (SENSOR_STATE[pinNo] <= '255') and (millis() > (SENSOR_TIME[pinNo] + 0.02)) and ( digitalRead(pinNo + 3) == LOW ) ) {

      SENSOR_STATE[pinNo] = SENSOR_STATE[pinNo] + 5;	// increase the brightness
      SENSOR_TIME[pinNo] = millis();					// reset to current time
	  
	   // loop to populate the required leds
      
        for ( int led_block = 0; led_block <= (NUM_LEDS_ON - 1)  ; led_block++ ){
          
          leds[(pinNo * NUM_LEDS_ON + led_block)] = CRGB( SENSOR_STATE[pinNo], SENSOR_STATE[pinNo], SENSOR_STATE[pinNo]);
      }
	
    }
  }
  FastLED.show(); // Update the LEDs
  delay(5);
}

Again, thank you for reading so far down.

I have a few notes and I would like to start with something else.

From Visual Basic to C++ and Arduino is not a big step :nerd_face:

Adafruit has a NeoPixel Überguide
Maybe you can have a look at it.
I prefer the FastLED library over the Adafruit Neopixel library, but you already use the FastLED :smiley:

I have a RGBWW ledstrip (RGB plus WarmWhite). That is so much prettier for me. The soft colored warm light is amazing. I don't know if the FastLED already supports RGBW, I had to add a trick.

The human eye sees brightness with a curve that is close to a 10log curve. That is very steep. Adjusting the brightness linear from 0...255 is ugly.

If you want to use millis(), then you should read the Blink Without Delay.

Writing code and making nice color changes can be done when the table is finished.
I like to start at the begin.
Are there 180 leds in the final project ? Then a Arduino Uno can do that.
Do you want to control it via Wifi or Bluetooth ?
A power supply of 5V 10.8A is needed. Are you going to buy a certified good power supply or the cheapest that you can find ? You could limit the brightness. Have you seen all the leds at maximum white brightness ? It is too much light !
Can a infrared proximity sensor see through epoxy resin ?

How are the leds organized ? You can design led sequences in a simulator, such as Wokwi. For example this metaballs simulation. Press the start button to start the simulation.

Hi Keopel,

Thank you so much for the reply!

Power is some thing I've started to look at. The website I nabbed this from linked to what looks like a professional power-supply that I was going to order.

I'm not sure of the exact number of leds, I need to do some more spec-ing of the final build. I think though it will probably be more like 320 (ish) with 40 proximity sensor each controlling (maybe)8 leds.

The warmwhite sounds very good. I'll look into that.

Regarding the IR proximity sensor, I'm thinking I'll either have to drill deep into the epoxy leaving maybe 2/3 mm for it to see through or maybe use a proximity sensor like the ttp223 (b) to go through it. I need to do some more research and testing on this. Though as I understand whether I use the IR or ttp223 the code would be the same.

Thank you for wokwi, I'll look into it.

How would you suggest I alter the brightness?

Thanks,

Adam

320 leds are probably too many for a Arduino Uno.
The high current can not go through the ledstrip, you have to power the ledstrip every 50 cm or 1 meter or so.

320 leds in small location such as a table ? You really have to turn on many leds and see how bright it is. Don't overdo it, start simple :pleading_face:
There are sheets to spread the light of the leds. I don't know what they are called, translucent something, diffuser ?

These work together:

#define BRIGHTNESS 255
...
FastLED.setBrightness(BRIGHTNESS);

It sets the overall brightness. In the code the brightness will still be set as 0...255, but that is scaled by the overall brightness setting.

The FastLED library can also set a maximum current, then it will dim the leds when too many leds are too bright.

If you don't like RGB leds in your mouse, your keyboard and your computer, then maybe the RGB(Warm)W is something for you.

About making it visual beautiful:
The brightness between 0 and 1 is a big difference. It is possible to keep all three R, G and B at a value 1 to avoid the transition or use a 12-bit ledstrip.
The rest of the brightness can be mapped via a table. For example only 10 possible brightness settings, mapped with a curve to 0...255.
If you use a floating point calculation, then it is possible to use the power of 10, as I did in my millis_soft_pulsating_led.ino. It is a sinus through a pow(10).
See the pow(10) in simulation: millis_soft_pulsating_led.ino - Wokwi Arduino and ESP32 Simulator

Hardware:

One thing to consider is how hard is your epoxy. If very hard it is likely able to rip the LEDs right off the strip over time and temperature. Also consider any "shrinkage" of the epoxy as it cures.

I can't say this is definitely an issue for your projects. But before you spend a lot of time on your project you might want to epoxy some LEDs and see.

I don't have a definitive answer but a thin coating of silicone conformal coating will go far to protect the LEDs.

@John,

You are right, the epoxy can mess up the leds. I've made that mistake in the past. I was going to cut a set of groves in the underside for the leds to to sit in.

@Koepel

Agreed 320 is probably a few to many. :slight_smile: I was looking at using a Arduino Mega, though.

I'll look at the soft pulsating wokwi, thanks.

Thank you both for the help

Will the complete ledstrip be in the epoxy resin ? My feeling tells me to use a bare ledstrip (not encapsulated ledstrips for outdoors) and use them without conformal coating and let the copper traces deal with the shrinking.

I have put electronics in epoxy without problem, but not a ledstrip.

Do you have a photo ?

Just thinking "out loud".... do they make outdoor addressable LED strips?

It is just a sleeve.

I have no photos of the failures unfortunately. Encasing leds in epoxy has been a bit hit and miss and this project is going to require a fair amount of testing and adjustment of the leds so I want to keep them accessible.

I have encased some simple 'xmas tree' white leds into a 'children's activity wall' so they illuminat an H when a light switch is pushed.

I tried making a night light using some usb powered RGD leds. I encased these in to epoxy and they just didn't light up after. I tried again and this time whilst they worked after the epoxy dried, however when sanding down the epoxy I broke one of the wires. :frowning:

Thank you for pointing me in the direction of wokwi. I've mocked up a circuit using some simple switches for the inputs and a set of addressable leds.

First point was to change the 0.02 to 20. d'oh, need to add 20 milliseconds each time not 0.02

 if ( (SENSOR_STATE[pinNo] >= '5') and (millis() > (SENSOR_TIME[pinNo] + 20)) and ( digitalRead(pinNo + 3) == HIGH ) ) {

The if statements in the code kind off work. However, if I set the switch(s) on/off it will fade in/out the required leds however it will keep doing it for a number of iterations and then stop. I don't have enough of a coding brain to work out why. I was hoping you could point me in the direction of a debugging tool so I can monitor the various values to see what they are doing. I've tried including TinyDebug.h but wokwi complains that it doesn't exist. Any ideas?

I would like to get the basic premise of the leds fading in and staying on and vice versa in the code now as I have the time to do it. I can do some testing with IR/ttp223 sensors through wood/epoxy now as well. But as to which leds and what scale to brighten them on, that is going to have to wait until summer when the main table is built.

Again thank you all for you help so far.

Wokwi can debug a sketch for the Arduino Mega 2560, but I could not make it work :weary:
https://docs.wokwi.com/gdb-debugging
Tinkercad can debug, but I think they only use the NeoPixel library.

When I see this: "(millis() > (SENSOR_TIME[pinNo] + 20))" then I want to spit out movie quotes. It seems like you are trying random code and hope that you feel lucky.
I think you have a implementation problem.

I found this introduction useful: https://www.tweaking4all.com/hardware/arduino/adruino-led-strip-effects/
You may check that, to see if you already know those basic things.

There is a NeoPixel example to do other things while a certain sequence is busy. There are many "NeoPixel"-alike libraries for newer boards with all kind of fancy things.
The FastLED has a timer for sequences.

Do you want to do other things while a certain sequence is running on the RGB leds ?
For example each individual block slowly fade out when a object is removed ? Then you need that FastLED timer. It is preferred over millis(), search for "EVERY_N_MILLISECONDS".

Then you need to describe what you want, without thinking in code.

:warning: There is something that I have encountered. With so many leds, the FastLED has its limits. There is an option to dither the colors, but the leds can not be updated very fast with so many leds. So the dithering is not always possible, which was a disappointment for my project. Also the Arduino Mega 2560 has its limits. In the end, not everything is possible that you might want. The less leds, the more you can do.

The movie quote is very apt. I have had some formal training in pascal over 25 odd years ago. However Most of my coding attempts before and after have been hatchet jobs to get things done. E.g search a log file for a sequence or macros in excel. None of it has been ‘in production’ so has never needed to be ‘correct’, it’s just needed to work. :slight_smile:

Thanks I’ll have a look at the fastled timer.

Adam

right, this is where I've got to with the code. It does what I want which is to fade in (to white) a block of leds if and input is received and fade out of the input is removed. It can do this across multiple inputs simultaneously. I've also put a small start up sequence that goes through all of the leds. I wouldn't say the code is the most elegant and I'm going to continue tweaking it so I can add the log10 fade in/out mentioned above. though the final colour and fade in/out will have to wait for the actual table to be built and tested on.

Thank you so much for your help so far. The examples you have pointed me towards have been very useful.

code:

#include "FastLED.h"


#define LED_TYPE    WS2811
#define NUM_LEDS 30
#define NUM_LEDS_ON 6
#define LED_PIN 2
#define NO_OF_INPUT 5
#define COLOR_ORDER GRB
#define brightness 255
unsigned long myTime;
unsigned long currentTime;
char SENSOR_STATE[NO_OF_INPUT];
int SENSOR_BRIGHTNESS[NO_OF_INPUT];
unsigned long SENSOR_TIME[NO_OF_INPUT];
int startupval = 0;

CRGB leds[NUM_LEDS];

void setup() {

  myTime = millis();
  FastLED.addLeds<LED_TYPE, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS);
  FastLED.setBrightness(brightness);
  // Set the 3 switch pins as inputs, from digital pin 3 to pin 5, set the SENSOR State to 0 (OFF) and SENSOR Time to the current time
  for (int pinNo = 0 + 3; pinNo <= NO_OF_INPUT + 3; pinNo++) {
    pinMode(pinNo, INPUT);

  }

}


void loop() {

  if (startupval == 0 ){
      startup();
   startupval = 1;

  }

  currentTime = millis();

  checkForButtonInput();

  // For statement to dim the all leds under these three conditions:
  // 1st condition: Sensor state is above 5, As the sensor state is being used to control the brightness this can't go below 0
  // 2nd condition: Time delay for the incremental fade, 0.02 of a second
  // 3rd condition: Touch sensor not active
  EVERY_N_MILLISECONDS( 10 ) {
	
    for (int pinNo = 0; pinNo <= (NO_OF_INPUT - 1)  ; pinNo++) {
    
      if ( (SENSOR_STATE[pinNo] == LOW ) and (currentTime > (SENSOR_TIME[pinNo] + 20)) and (SENSOR_BRIGHTNESS[pinNo] > 5 )) {
    
        SENSOR_BRIGHTNESS[pinNo] = SENSOR_BRIGHTNESS[pinNo] - 5; 	// decrement the brightness
        SENSOR_TIME[pinNo] = millis(); 					// reset to current time 
    
  //  populate the required leds
  
        lightLEDS (pinNo);

      }
  
  // For statement to increment all leds to a maximum brightness under these three conditions:
  // 1st condition: Sesnor state is below 255, As the sensor state is being used to control the brightness this can't go above 255
  // 2nd condition: Time delay for the incremental brightness increase, 0.02 of a second
  // 3rd condition: Touch sensor is active
  
    if ( (SENSOR_STATE[pinNo] == HIGH) and (currentTime > (SENSOR_TIME[pinNo] + 20)) and (SENSOR_BRIGHTNESS[pinNo] < 255 )) {

      SENSOR_BRIGHTNESS[pinNo] = SENSOR_BRIGHTNESS[pinNo] + 5;	// increase the brightness
      SENSOR_TIME[pinNo] = millis();					// reset to current time
	  
	  // light the required leds
      
      lightLEDS (pinNo);  
	
      }
 
    } 

  }

  FastLED.show(); // Update the LEDs
 
 }

 void  checkForButtonInput() {

  for (int pinNos = 0; pinNos <= (NO_OF_INPUT - 1)  ; pinNos++) {
  
    SENSOR_STATE[pinNos] = digitalRead(pinNos + 3);
  
  }

}

void lightLEDS (int pinNolight) {

  for ( int led_block = 0; led_block <= (NUM_LEDS_ON - 1)  ; led_block++ ){
          
    leds[(pinNolight * NUM_LEDS_ON + led_block)] = CRGB( SENSOR_BRIGHTNESS[pinNolight], SENSOR_BRIGHTNESS[pinNolight], SENSOR_BRIGHTNESS[pinNolight]);
        
  }

}

void startup () {

  delay(1000);

  for (int i = 1; i <= NUM_LEDS; i++){ 
    leds[i] = CRGB(random(10, 255), random(10, 255),random(10, 255) );
      FastLED.show(); // Update the LEDs
       delay (100);
      leds[i] = CRGB(0, 0,0);
      FastLED.show(); // Update the LEDs
  }
  for (int pinNo = 0 + 3; pinNo <= NO_OF_INPUT + 3; pinNo++) {

    SENSOR_STATE[pinNo] = HIGH;
    SENSOR_TIME[pinNo] = myTime;
    SENSOR_BRIGHTNESS[pinNo] = 0;
  }


}

What if you call the startup() function at the end of setup() ?
I think the result is the same.

Could you put the pins of the inputs also in an array please.
Suppose that sensors are connected to pin 3, 20, 4, 8 and 10.

const int sensorPins[5] = { 3, 20, 4, 8, 10 };

void setup()
{
  for( int i=0; i<5; i++)
  {
    pinMode( sensorPins[i]), INPUT);
  }
}

void loop()
{
  for( int i=0; i<5; i++)
  {
    if( digitalRead( sensorPins[i]) == LOW)
      Serial.println( "Something detected");
  }
}

That is so much better, isn't it ?

Hi Koepel,

Again, thank you so much for your input. D'oh I'll call startup() in setup and add an array for the pins too.

Adam

Hi All,

Thank you again for your time.

These are the power calculation I've done.

180 NeoPixels × 60 mA ÷ 1,000 = 10.8 Amps
20 ir sensors x 20 mA / 1,000 = 0.4 Amps
Arduino Mega = 73.19 mA

The below power source should be more than enough as it's 5v with a max of 20 Amps

I have a few questions on powering the various components

Firstly, as I understand, best practice seems to be adding a 300 to 500 Ohm resistor between the Arduino data output pin and the input to the first NeoPixel/addressable led to stop any current spikes blowing the first 3/4 leds?

Theoretically I can power the Arduino directly from this power source by connecting into the 5v and GND pins but as this bypasses the voltage regulator and all the safety measures present on the Arduino it doesn't seem like a good idea.

I could add another transformer like the one below to convert from 240v to 12 volts and power the Arduino through the barrel connector. Is there any other way I could do this?

[https://www.amazon.co.uk/dp/B07FZN9YMV/ref=sspa_dk_detail_2?pd_rd_i=B07FZK9BCN&pd_rd_w=AVpOh&pf_rd_p=828203ef-618e-4303-a028-460d6b615038&pd_rd_wg=pkemU&pf_rd_r=ZESQDPNVB2SZ911GR7X0&pd_rd_r=309c22bc-3c4c-4fcc-9137-782aa6925a85&s=diy&spLa=ZW5jcnlwdGVkUXVhbGlmaWVyPUEzVThRSVRWRExRT1U2JmVuY3J5cHRlZElkPUEwMzQ2NzI0MkFRUzFNOVRHMUU0UCZlbmNyeXB0ZWRBZElkPUEwNjMxMDU1VFU4N0tEM1BIMVVSJndpZGdldE5hbWU9c3BfZGV0YWlsJmFjdGlvbj1jbGlja1JlZGlyZWN0JmRvTm90TG9nQ2xpY2s9dHJ1ZQ&th=1](https://12v DC PSU)

There seems to be a few differing opinions on how to power addressable led strips. Power in at just one end, both ends, both ends and the middle...

With the project I'm working on I've taken the view that as each IR sensor will switch on/off a single strip of 9 leds, I was going to send power to each induvial strip from a central source rather than chain the power from one to another. See diagram below. I have been reading that it is a good idea to connect a 1000 uF capacitor across the vcc and gnd points at the beginning of each led strip as a filter cap to filter out voltage ripples? Is this a good idea or even necessary?

The psu has two power channels. I was wondering if it is good practice to put the leds on one and the sensors on the other. This will require more cabling but keeps the sensors away from possibly high current surges when the leds are lit?

Some more details:

If all of the leds are lit at once that's going to be 10.4 amps on the first wires out of the psu to the first distribution point. These will need slightly more heavy duty than the following ones I'm thinking

I was going to use one of these to turn the whole system on and off: [https://www.amazon.co.uk/dp/B07T5D39R3/?coliid=IQL0O7SW69NV&colid=LTS72HME6794&psc=1&ref_=lv_ov_lig_dp_it](https://mains power switch)

Also, is it worth putting a fuse before both the sensors and led strips, if so can anyone recommend some parts please.

On the coding side, rather than having the leds stay on permanently if the sensor is tripped, I'm thinking of having then start to fade out after 5 mins as a safety precaution. This I will look into when the top is built and I can see how much heat is generated.

Is there anything else I have missed?

Diagram: (please excuse my lack of fritzing skills)

image

Thanks,

Adam

There is no need to turn the leds off after 5 minutes.

The resistor to the first Neopixel and the capacitors are good. Use them.

Connect the GNDs. For example a star-ground, right next to the Arduino board.
The pink wires in your drawing have no meaning as long as there is no GND with it.

You may power the sensors with the same power supply. Assuming that its noise does not influence the sensors. But you must connect the GNDs.

Is a single power supply for everything possible ?
A led driver as a 12V power supply scares me. Open it and make a photo so we can have a laugh or cry or both :scream:

Some say that powering the Arduino board via the 5V output pin is preferred.
Some say that you can blow the voltage regulator on the Arduino board and even damage the computer (connected via USB) that way.
I prefer to lower the current when using the 5V pin. It is tricky. Let's see what the others say.

Hi Keopel,

Thank you again for the reply.

I’m slightly confused by what you mean by the pink wires not having any effect unless grounded.

What have I missed:
The ir sensors and led strips will be connected to the +v and -v of the power supply. Through this to ground/earth.

Is the issue if I connect the arduino to another supply then the grounds will be different.

So far the reading I’ve done on this is confusing to synthesis least.

Could you point me to a circuit diagram I could look at to see what you mean please.

Thanks,

Adam

Suppose the battery gives a signal and the led receives a signal.
This circuit will not work:
afbeelding

Add a pink wire. It still will not work. The pink wire has no meaning:
afbeelding

The pink wire has only a meaning when the GND is connected:
afbeelding
A single wire with a signal is nothing, it becomes something when there is a GND.

This is an Arduino board reading a sensor. Nothing is wrong with it:
afbeelding

A power supply is added, and the GND is connected to the Arduino GND:
afbeelding

Adding a load (a ledstrip or a motor) might make the sensor unreliable. The GND near the sensor is not the same as the GND near the Arduino board:
afbeelding

If you use a different power supply for the Arduino, then you have to connect the GND.

Thank you so much!