Using a Led Matrix As a Scanner

Ordinary digital cameras work by using a large array of light sensors to capture light as it is reflected from an object. In this experiment, I wanted to see whether I could build a backwards camera: instead of having an array of light sensors, I have just a single sensor; but I control each of 1,024 individual light sources in a 32 x 32 LED matrix.The way it works is that the Arduino illuminates one LED at a time, while using the analog input to monitor changes in the light sensor. This allows the Arduino to test whether the sensor can "see" a particular LED. This process is repeated for each of the 1,024 individual LEDs rapidly to generate a map of visible pixels.If an object is placed between the LED matrix and the sensor, the Arduino is able to capture the silhouette of that object, which is lit up as a "shadow" once the capture is complete.BONUS: With minor tweaks, the same code can be used to implement a "digital stylus" for painting on the LED matrix.For this project, I used the following components:AdaFruit also sells an Arduino shield which can be used instead of jumper wires.As I had some Tindie credits, I got my matrix from Tindie, but the matrix from AdaFruit seems to be identical, so either one should work.The phototransistor came from my decades old collections of parts. It was a clear 3mm part labeled as a TIL78. As far as I can tell, that part is meant for IR and comes either a clear case or a dark casing that blocks visible light. Since the RGB LED matrix puts out visible light, the clear version must be used.This TIL78 appears to have been discontinued, but I imagine this project could be made using contemporary phototransistors. If you find something that works, let me know and I will update this Instructable!Normally, you would need a resistor in series with the phototransistor across power, but I knew that the Arduino had the ability to enable an internal pull-up resistor on any of the pins. I suspected that I could take advantage of that to hook up the phototransistor to the Arduino without any additional components. It turned out my hunch was correct!I used wires to connect the phototransistor to the GND and A5 pins on the Arduino. I then created a sketch that set the A5 pin as an INPUT_PULLUP. This is normally done for switches, but in this case it provides power to the phototransistor!This sketch prints values to the serial port corresponding to the ambient brightness. By using the handy "Serial Plotter" from the "Tools" menu of the Arduino IDE, I can get a moving plot of ambient light! As I cover and uncover the phototransistor with my hands, the plot moves up and down. Nice!This sketch is a nice way to check whether the phototransistor is wired up with the right polarity: the phototransistor will be more sensitive when hooked up one direction versus the other.To wire up the matrix to the Arduino, I went through this handy guide from Adafruit. For convenience, I pasted the diagram and pinouts into a document and printed a quick reference page to use while wiring everything up.Take care to ensure the tab on the connector matches the one in the diagram.Alternatively, for a cleaner circuit, you could use the RGB matrix shield that AdaFruit sells for these panels. If you use the shield, you will need to solder in a header or wires for the phototransistor.I screwed down the fork terminals on the matrix power leads to the jack adapter, making sure the polarity was correct. Since part of the terminals were left exposed, I wrapped the whole thing up with electrical tape for safety.Then, I plugged in the power connector and ribbon cable, being careful not to disturb the jumper wires in the process.You will need to install the "RGB matrix Panel" and the AdaFruit "Adafruit GFX Library" in your Arduino IDE. If you need help doing this, the tutorial is the best way to go.I suggest you run some of the examples to make sure your RGB panel works before proceeding. I recommend the "plasma_32x32" example as it is quite awesome!Important note: I found that if I powered up the Arduino before I plugged in the 5V supply to the matrix, the matrix would light up dimly. It appears that the matrix tries to draw power from the Arduino and that's definitely not good for it! So to avoid overloading the Arduino, always power up the matrix before you power up the Arduino!Now, load the Arduino sketch for scanning the matrix. I have provided the Arduino source code. Once you have loaded it, you should see a flash of light sweeping the matrix every few seconds.If you bring the phototransistor close to the matrix, you should see that LEDs near the phototransisor are illuminated.Try moving the phototransistor further and closer to the matrix to see how it behaves like a flashlight. If you place an object on the matrix and hold the phototransistor above it, you should be able to capture a "shadow" of the object!There are a few parameters you can tweek in the code:If the detection isn't working well, you can try increasing READING_PER_PIXEL and THRESHOLD. Set CLEAR to false to get a paintbrush like effect where each new scan adds more "paint" to the canvas. Set INVERT to true for a negative effect, where the matrix is normally lit, but the phototransistor darkens what it can "see".After some experimentation, I found that the best way to detect whether a pixel is visible from the sensor was to take pairs of analog readings from the sensor: one reading when the LED is off and another reading when the LED is on. If the sensor cannot see the LED, then the readings will be practically the same; if the sensor can see the LED, the readings will be different.To increase the sensitivity, I take multiple readings while using the OE (output enable) line to turn the LED on and off. I use two accumulators to sum the readings taken when the LED is off vs when the LED is on. I then compare difference between these two sums against a threshold to determine whether the value exceeds some threshold, giving me a decision on whether the LED is within line of sight from the sensor.For scanning the matrix, I manipulate the data lines directly, as this is more efficient than using the AdaFruit library to paint pixels. To disable the AdaFruit library, I shut off interrupts prior to beginning a scan. Since the AdaFruit library works by using interrupts, this allows me to take control of the matrix temporarily. The matrix has six shift registers, corresponding to the R, G and B colors of an entire rows of pixels in the upper and lower halves of the matrix. There is also a latch control line (LAT), which copies the values from the shift register to the LED drivers. Four address lines (A, B, C and D) select which rows of the upper and lower half are active and an OE (output enable) turns the LED drivers on and off. In normal operation, the latch keeps a row illuminated with previous values while a new replacement row is shifted into the shift registers. Once the entire row has been loaded, the new values are latched and the process repeats for the next row. This manner of updating requires an entire row to be written, even if only one pixel needs to be written.For scanning, I chose to take advantage of the shift register, but not the latching functionality. I set the latch control line (LAT) to HIGH, making it so the contents of the shift register are loaded into the LED drivers immediately on each CLK pulse. Once I illuminated the first pixel, each pulse on the clock line (CLK) causes the lit pixel to get pushed down the row to the next pixel. In so doing, I can push the illuminated pixel down the row to scan the entire row.For each position in the row, I use the OE (output enable) line to strobe the pixel on and off while taking the readings from the light sensor. Once I have enough readings to make a determination of whether that pixel is visible or not, I write a color to the AdaFruit library's framebuffer (while scanning, I can still write pixel values to the library's framebuffer, even though the library is temporarily suspended).After all the rows have been scanned. I re-enable interrupts, which causes the AdaFruit library to refresh the matrix with the data in the buffer until I am ready for the next scan.

empfohlene Artikel
Info. Wissen Nachrichten
Technology: Overhead Lights Ensure the Price Is Right ...
By LEIGHT DAYTON in SYDNEY To keep the prices of the 10 000 different items in an average supermarketcorrectly marked, an Australian company has developed a system that sendsdata to electronic price labels on the shelves through the supermarket'soverhead lights. A light detector on the label instantly picks up the signal. The indoor light interactive display system (ILID), conceived by TrevorGray of the company TCG-ILID in Melbourne, is one of three approaches forcoordinating prices on the shelves with those at the checkout. The Frenchfirm Epsilanne wires each shelf label and cash register directly to thesupermarket's computer, while Telepanel and Pricelink in the US put tinyradio receivers on the shelf labels to pick up information. In the ILID system, price information is sent to a modulator hookedinto the lighting's power supply. The modulator slightly changes the waveformof the current to insert the information, according to Terry Polkinghorn,general manager of TCG-ILID. Some of the peaks of the waveform have a 'blip'superimposed upon them and some do not. The blips and non-blips form a digitalcode that contains the addresses and other information on particular products. The current passes through existing wiring to the overhead lights, eitherfluorescent, incandescent or halogen, which then beam out the data. Labelswill pick up the information if the address corresponds to that product.Polkinghorn claims shoppers do not notice a change in the lighting. By touching the cover of the label's light sensor for a few seconds,shoppers can see a second display with more details about the product, suchas the unit price of the item or special offers. Staff can use a light-emittingwand to change displays or read information not available to customers,such as instructions for stacking shelves. Managers can create up to 20different displays. According to Polkinghorn, the system will be tested in a supermarketin Melbourne within two months. TCG-ILID is talking with the British supermarketchain Tesco as well as European, American and Japanese companies aboutfurther trials.
2021 07 08
Predator-Proof Nests May Help Save Endangered Parrots
They're a swift parrot's worst nightmare: cute but deadly sugar gliders. As deforestation on the island of Tasmania spreads to accommodate growing agriculture and logging industries, the region's critically endangered swift parrot population has dwindled to a mere 2,000. In addition to losing access to the massive 250-foot trees where they lay their eggs, swift parrots have had a more difficult time evading the resilient population of sugar gliders. The palm-sized mammals resemble squirrels but with larger eyes and more rotund bodies. They were brought to the region from mainland Australia as pets in the mid-19th century and, after being released into the wild, became an invasive species. They've been uniquely good at adapting to regions subjected to deforestation, said Dejan Stojanovic, a conservation scientist from the Difficult Bird Research Group. Stojanovic says the conservation group's name was inspired by the difficulty researchers have in studying the small, bright green birds. While their nesting grounds are on the island of Tasmania, they also visit Australia proper and small surrounding islands in search of flowering trees. Not all trees flower every year, the researcher said, and while the birds have uniquely adapted to figuring out which trees supply their food source, scientists are still catching up. "I always describe them as hyper caffeinated," said Stojanovic. That's because the birds quickly zip through the trees, chasing each other and "singing their heads off" to attract mates. It's the habitats the scientists most easily located that have caused them the largest source of anxiety about the birds' descent toward extinction. Their breeding grounds, the sites most critical to keeping their population numbers healthy, are infested with sugar gliders that feast on swift parrots' babies and eggs. Stojanovic and a team of researchers from the Australian National University are hoping they can outsmart the small predators with a simple habitat they're calling the "possum keeper outer." "It's a great name isn't it?" Stojanovic said, laughing. Despite the box's lighthearted name it's been seriously successful at protecting the small birds from the island's invaders. The parrots have taken to the boxes, using them as nests. To keep the sugar gliders out, a small mechanized rectangle is attached to the outside of the box, near the circular hole the birds use to enter and exit. It's controlled by a light sensor that moves the door over the hole when it's dark, and opens it when it senses morning light. The simple concept works because swift parrots are diurnal (awake during the day), while sugar gliders are nocturnal. In other words, when the parrots go in their nest boxes for the night, the door closes behind them, keeping them safe from predatory sugar gliders until the morning, when the predators are no longer active. It's one small but effective way the Difficult Bird Research Group has attempted to protect the few "swiffies," as Stojanovic affectionately refers to them, that are left in the wild. "I'm optimistic, but I'm also extremely cautious, and my caution exceeds my optimism," Stojanovic said. He emphasized that the boxes prevent sugar gliders from preying on parrot babies, but it's only a band aid on a gaping wound. "At the end of the day if we continue to lose habitat-and there don't appear to be concrete changes to stop logging-it seems like deforestation is locked in. If that's the case, then all of this that we're doing is ultimately for nil."
2021 07 02
Schnell verbindung



Über uns

Kontaktieren Sie uns


Das moderne Haus

Landschafts haus

Vintage Haus

Guangzhou DaLong CNC Machinery Technology Co.Ltd spart keine Kosten, wenn es darum geht, sicherzustellen, dass wir über die neueste und beste Ausrüstung verfügen.


Unternehmens profil

Unternehmens geschichte


Copyright © 2021-2035 Guangzhou DaLong CNC Machinery Technology Co.Ltd |Seitenverzeichnis

Großhandel mit Maschinenzubehör Melayu  |   Fräsmaschinenhersteller العربية  | Erodiermaschinenfabrik OEM