I have a LED strip controlled by a trinket M0. I have connected Hall sensors/switches to individual LEDs to turn on/off their power supply. Is there a way to programmatically detect (in a sketch) which LED is turned on/off by the corresponding Hall switch. I need this information to log the LED's ID (number in the strip) and apply further control functions to it (e.g. keep it turned on for some predefined amount of time - delay). Any suggestions are greatly appreciated.
Thanks!
Val
How to detect programmatically when a RGBW LED is disconnect
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- vnenov
- Posts: 33
- Joined: Tue Sep 08, 2009 1:54 am
- adafruit_support_bill
- Posts: 88093
- Joined: Sat Feb 07, 2009 10:11 am
Re: How to detect programmatically when a RGBW LED is discon
It is not clear from your description: Are the leds controlled by the Trinket or the hall switch? A diagram and some code would be helpful.
- XRAD
- Posts: 754
- Joined: Sat Nov 19, 2016 3:28 pm
Re: How to detect programmatically when a RGBW LED is discon
just read the individual hall sensors...you may have to multiplex if you have more sensors than pins...then use that data in a function to turn on/off/delay whichever pixel you want
- vnenov
- Posts: 33
- Joined: Tue Sep 08, 2009 1:54 am
Re: How to detect programmatically when a RGBW LED is discon
Thanks for your prompt replies. Sorry for not being clear in my initial description. Attached are the wiring diagram and the basic sketch.
I have 150 LEDs strip. There is one Hall sensor per LED. I have cut off the direct 5V power to each LED and replaced it with the Hall switch output. I am using the trinket to set all LEDs to white (or any other color). When the circuit is powered on initially all pixels are OFF. When a Hall switch is turned on by a magnet the corresponding pixel lights up. I want to be able to detect which Hall switch is turned on. Of course there are not 150 IO pins on a Trinket. I can connect one IO pin to the OUT of all Hall switches. So the question is how to read out which Hall Switch is turned ON (there might be more than one of them ON at the same time). How do I do the multiplex read-out of the Hall switches states in the code? Is it even possible?
My ultimate goal is to move a magnet along the LED strip and to have it light up the pixels that it is going over. I also want to keep those pixels turned ON for a while (i.e. leave a trail of light up pixels). It will be useful also to log the pixel IDs and the times they were turned On/Off.
I have 150 LEDs strip. There is one Hall sensor per LED. I have cut off the direct 5V power to each LED and replaced it with the Hall switch output. I am using the trinket to set all LEDs to white (or any other color). When the circuit is powered on initially all pixels are OFF. When a Hall switch is turned on by a magnet the corresponding pixel lights up. I want to be able to detect which Hall switch is turned on. Of course there are not 150 IO pins on a Trinket. I can connect one IO pin to the OUT of all Hall switches. So the question is how to read out which Hall Switch is turned ON (there might be more than one of them ON at the same time). How do I do the multiplex read-out of the Hall switches states in the code? Is it even possible?
My ultimate goal is to move a magnet along the LED strip and to have it light up the pixels that it is going over. I also want to keep those pixels turned ON for a while (i.e. leave a trail of light up pixels). It will be useful also to log the pixel IDs and the times they were turned On/Off.
- kcl1s
- Posts: 1512
- Joined: Tue Aug 30, 2016 12:06 pm
Re: How to detect programmatically when a RGBW LED is discon
Just my opinion but I believe all your work is in vain. When you cut power to a pixel I believe you will stop the chip inside from being able to pass along data to pixels farther down the chain. This will not allow manipulation of those down stream pixels as you state you want to do. They will stay the color assigned the last time they got a signal.I have cut off the direct 5V power to each LED and replaced it with the Hall switch output
Neopixel control is one way - out. There is no feedback input from the strip.Is there a way to programmatically detect (in a sketch) which LED is turned on/off by the corresponding Hall switch. I need this information to log the LED's ID (number in the strip) and apply further control functions to it (e.g. keep it turned on for some predefined amount of time - delay).
Fellow hobbyist
Keith
- kcl1s
- Posts: 1512
- Joined: Tue Aug 30, 2016 12:06 pm
Re: How to detect programmatically when a RGBW LED is discon
Looking at your code you say it works. If that is true that the digital signal jumps through un-powered pixels then disregard my last post. It looks like you are using a different pixel than the sk6812 I am familiar with.
Keith
Keith
- adafruit_support_bill
- Posts: 88093
- Joined: Sat Feb 07, 2009 10:11 am
Re: How to detect programmatically when a RGBW LED is discon
I don't think that can work with a chip like the WS2812. As Keith says, with no power to the chip there won't be any communication through the chip either. You could probably the hall triggers work with discrete LEDs or maybe an analog LED strip. But you would not be able to address teh pixels programmatically.
- vnenov
- Posts: 33
- Joined: Tue Sep 08, 2009 1:54 am
Re: How to detect programmatically when a RGBW LED is discon
Keith and Bill, thanks for the replies. The WS2813 has "Main feature: One pixel damaged will not affect the other LEDs' working, Dual signal wires version, Signal can jump to transfer". So if I interrupt one of those wires going to a LED with a switch (Hall or basic push-button) that should not affect the rest of the strip. I have not tested this yet (can't do it right now) but am just wondering what your thoughts are.
- adafruit_support_bill
- Posts: 88093
- Joined: Sat Feb 07, 2009 10:11 am
Re: How to detect programmatically when a RGBW LED is discon
The data sheet says it has dual inputs to protect against damaged circuitry on the primary channel. but it does not say that whether the backup input channel will function with no power. I guess you will just have to experiment with it to find out.
- oesterle
- Posts: 806
- Joined: Tue Sep 17, 2013 11:32 pm
Re: How to detect programmatically when a RGBW LED is discon
Hi, vnenov!
Interesting work!
I would consider separating the sensor circuitry from the LED circuitry. Then, programmatically, you can turn on/off any pixel using data. Or you could do a smooth fade in/out. Or change the color of an LED.
Currently you use binary on/off Hall effect sensors, like the Adafruit Hall effect sensor. The current implementation locks in a specific approach due to a fixed, wired interaction between your sensors and LEDs.
I'm imagining running the sensors in parallel with the strip, possibly still using the power from the strip for each sensor, but routing the sensor output back to the microcontroller, rather than to each LED.
To have more inputs for the Hall sensors, you could use an Adafruit ATSAMD09 Breakout with seesaw.
This also may reduce the number of sensors you actually need. Maybe you only need one sensor every 3 LEDs, and can interpolate the data between any two sensors.
Separating the sensors (inputs) from the actuators (LEDs), and placing the microcontroller in between would make your project more software-defined and flexible in how it interprets sensor data, and what you do with the LEDs in response. It will also give you more flexibility in trying different sensors, or different LED strips. In the future, you could use inexpensive accelerometers, gyroscopes, and/or magnetometers.
Just some ideas. What are you making?
Cheers,
Eric
Interesting work!
I would consider separating the sensor circuitry from the LED circuitry. Then, programmatically, you can turn on/off any pixel using data. Or you could do a smooth fade in/out. Or change the color of an LED.
Currently you use binary on/off Hall effect sensors, like the Adafruit Hall effect sensor. The current implementation locks in a specific approach due to a fixed, wired interaction between your sensors and LEDs.
I'm imagining running the sensors in parallel with the strip, possibly still using the power from the strip for each sensor, but routing the sensor output back to the microcontroller, rather than to each LED.
To have more inputs for the Hall sensors, you could use an Adafruit ATSAMD09 Breakout with seesaw.
This also may reduce the number of sensors you actually need. Maybe you only need one sensor every 3 LEDs, and can interpolate the data between any two sensors.
Separating the sensors (inputs) from the actuators (LEDs), and placing the microcontroller in between would make your project more software-defined and flexible in how it interprets sensor data, and what you do with the LEDs in response. It will also give you more flexibility in trying different sensors, or different LED strips. In the future, you could use inexpensive accelerometers, gyroscopes, and/or magnetometers.
Just some ideas. What are you making?
Cheers,
Eric
- vnenov
- Posts: 33
- Joined: Tue Sep 08, 2009 1:54 am
Re: How to detect programmatically when a RGBW LED is discon
Thank you Eric, for the great ideas. I will most definitely follow up on some of them. Will try to put the sensor network in parallel with the LED network and use the ATSAMD09 https://www.adafruit.com/product/3657 to read out the states of the individual Hall (or other) sensors. I have never worked with the ATSAMD09 before but looks very useful.
I am trying to make a rectangular LED matrix which can function as a drawing board. All pixels are off initially. A pointer (stick) with a magnet on the tip can be used to draw curves with different colors and intensities on the board. A BlueFruit Feather will be good for that. That's it in a nutshell. I can see many different practical applications for this kind of a "drawing board".
I am trying to make a rectangular LED matrix which can function as a drawing board. All pixels are off initially. A pointer (stick) with a magnet on the tip can be used to draw curves with different colors and intensities on the board. A BlueFruit Feather will be good for that. That's it in a nutshell. I can see many different practical applications for this kind of a "drawing board".
- XRAD
- Posts: 754
- Joined: Sat Nov 19, 2016 3:28 pm
Re: How to detect programmatically when a RGBW LED is discon
there are 128 pin GPIO expander boards available....but they need more computing power than a trinket. that would give you 2 pixels per sensor. You would still read the sensor then drive the appropriate pixels.
- vnenov
- Posts: 33
- Joined: Tue Sep 08, 2009 1:54 am
Re: How to detect programmatically when a RGBW LED is discon
XRAD, which 128 pin GPIO expander would you recommend? When I searched the Adafruit Store for "128 pin GPIO expander" the only thing that popped out was the "Adafruit GPIO Expander Bonnet - 16 Additional I/O over I2C" https://www.adafruit.com/product/4132 for Raspberry Pi.
Also, would an "Adafruit Feather 32u4 Bluefruit LE" ( https://www.adafruit.com/product/2829 ) instead of a Trinket M0 have sufficient power to drive the project?
Thanks for your help!
Also, would an "Adafruit Feather 32u4 Bluefruit LE" ( https://www.adafruit.com/product/2829 ) instead of a Trinket M0 have sufficient power to drive the project?
Thanks for your help!
- XRAD
- Posts: 754
- Joined: Sat Nov 19, 2016 3:28 pm
Re: How to detect programmatically when a RGBW LED is discon
there is one for rasberry Pi, Raspberry Pi - I2C 23017 x8 - 128 GPIO Board. May not be sold on this site. On a side note, although we think of ws2812 leds as only an input device, they are actually input output devices. So for example, you can cut any length of neopixels strips and the first D in led will always be #1 (or '0') and the next led will be #2, etc... Why, because the onboard microchip reads the incoming 'driver program' bits and uses the first 'set' to drive the first led. Then the onboard led driver chip 'removes' this bit segment and sends out the remaining bits. Each time this happens, the 'driver program' gets a bit shorter, and the next in line chip just reads the next first set of RGB data. Pretty cool. You could actually read this data if you could compare the original incoming 'driver program' and compare it to the changed program, and thereby determine which neopixel you are writing to or have written to, BUT this would require a lot of work.
You idea is absolutely possible, but the easiest way is to multiplex the sensors, 128 sensors to be read, use that data to then affect your neopixel loop, and spit back out the correct neopixel driver sequence/display. Unfortunately, it would be 2 pixels per sensor which decreases your display density. Or get x2 128 boards.
Alternatively, you could have about 60 independent trinkets(5 pins available), each one reads up to 4 hall sensors , and independently drives a strip of 4 neopixels. This way is easier on code, but less practical due to all the uploading. So you could move up to a larger processor like M4 or new teensy, many more I/O pins..... The basically you could just build say a 25 sensor block with 5x5 sensors and neopixels, and mass produces these, and then just assemble as many blocks as you like.
You idea is absolutely possible, but the easiest way is to multiplex the sensors, 128 sensors to be read, use that data to then affect your neopixel loop, and spit back out the correct neopixel driver sequence/display. Unfortunately, it would be 2 pixels per sensor which decreases your display density. Or get x2 128 boards.
Alternatively, you could have about 60 independent trinkets(5 pins available), each one reads up to 4 hall sensors , and independently drives a strip of 4 neopixels. This way is easier on code, but less practical due to all the uploading. So you could move up to a larger processor like M4 or new teensy, many more I/O pins..... The basically you could just build say a 25 sensor block with 5x5 sensors and neopixels, and mass produces these, and then just assemble as many blocks as you like.
- vnenov
- Posts: 33
- Joined: Tue Sep 08, 2009 1:54 am
Re: How to detect programmatically when a RGBW LED is discon
Thank you XRAD for the very insightful comments and practical suggestions. It's good to have different design options. So, as usual, it boils down to practicality (simplicity of code and cost per unit "pixel/sensor" including parts and labour:-). I will experiment with different options and at some point will post my solution.
BTW, I found a "Waveshare MCP23017 IO Expansion Board I2C Interface Expands 16 I/O Pins for Raspberry Pi / micro:bit / Arduino / STM32 etc" ( https://www.aliexpress.com/item/32946398282.html ) which supposedly has: "The MCP23017 IO Expansion Board expands 2 signal pins as 16 I/O pins based on the I2C bus, up to 8 MCP23017 IO Expansion Board can be used at the same time, providing up to 128 I/O pins, it is compatible with both 3.3V and 5V levels."
As for the LEDs as input/output devices, it will be great if someone with more programming experience than me writes a program to compare the original "driver program" with the one that is active at a point in time after the n-th bit has been "cut out".
BTW, I found a "Waveshare MCP23017 IO Expansion Board I2C Interface Expands 16 I/O Pins for Raspberry Pi / micro:bit / Arduino / STM32 etc" ( https://www.aliexpress.com/item/32946398282.html ) which supposedly has: "The MCP23017 IO Expansion Board expands 2 signal pins as 16 I/O pins based on the I2C bus, up to 8 MCP23017 IO Expansion Board can be used at the same time, providing up to 128 I/O pins, it is compatible with both 3.3V and 5V levels."
As for the LEDs as input/output devices, it will be great if someone with more programming experience than me writes a program to compare the original "driver program" with the one that is active at a point in time after the n-th bit has been "cut out".
Please be positive and constructive with your questions and comments.