📜 ⬆️ ⬇️

Photogram without photo paper



The photogram is a very interesting art, at one time it was even promoted in television programs. You place objects on photographic paper, you exhibit from the direction at which the most interesting silhouette is obtained, you manifest, fix - and the work is ready. But now photo paper at every step does not buy. And what if the photogram after the photo to make digital?

For this, a long-known scanner with a running beam is suitable, only today, instead of a CRT, it will be more convenient to use an LED array in it. It is even better: the tube has a slight afterglow, the LEDs do not. The sensor will be a TIL78 phototransistor, outwardly indistinguishable from the LED (the output of the base is not displayed outside, but it is not needed). This phototransistor is discontinued, it can be replaced by many similar ones.
')
The phototransistor must be connected to the common wire with an emitter, a collector to the A5 input of the Arduino UNO, then fill in and run a small debugging sketch:

#define SENSOR A5 void setup() { Serial.begin(9600); pinMode(SENSOR, INPUT_PULLUP); } void loop() { // Read analog value continuously and print it Serial.println(analogRead(SENSOR)); } 

The program, in particular, activates the pull-up resistor built into the Arduino, so an external one is not needed. In the Arduino IDE menu, select Tools - Serial Plotter, and observe the illumination graph. Since the pin of the phototransistor is not marked on it, the polarity of its connection is determined experimentally.

32x32 LED matrix with built-in control device is connected as follows:



The matrix cannot be powered by the Arduino, it needs an external source of 5 V, 4 A. We connect it as follows:



We always supply power first to the matrix, then to the Arduino, remove power in the reverse order. We “pump” the Arduino IDE with the necessary libraries and check the matrix as described here . When everything works, fill in the sketch for photograms.

You can try to vary the parameters in it:

 static constexpr uint8_t READINGS_PER_PIXELS = 1; static constexpr uint8_t THRESHOLD = 15; static constexpr bool INVERT = false; static constexpr bool CLEAR = true; 

The first two parameters can be used to adjust the sensitivity, the third - to switch between positive and negative, the fourth - to enable the imposition of each subsequent image on the previous one. Enjoying a large animated GIF .

The best way to determine if the light on the phototransistor was from the matrix turned out to be this: to compare the results with the LED turned off and on. If the LED above the point of the object being read at the moment is blocked, they will be the same, if not blocked, they will be different. The LED turns on and off several times by switching the OE line (output enable), the reading results are summed up in two batteries: in one - when the LED is off, in the other - when it is turned on. The result of subtracting these amounts is compared with the threshold value.

The matrix contains six shift registers corresponding to whole rows of red, green, and blue LEDs in the upper and lower halves. The LAT (latch) line controls the buffer transferring the values ​​from the shift registers to the LED drivers. Four address lines A, B, C, D allow you to select the active line in the upper and lower halves, and the OE line allows you to disable and enable drivers.

Usually, the previous data is stored in the buffer and sent to the LED drivers, while the new ones are written to the shift registers at this time. After the line has been completely written, they are transferred to the buffer, and the process is repeated for the next line. Even if you need to change the state of only one pixel, you will have to overwrite the entire line.

Here, the matrix is ​​not used as intended - for scanning, so the author used the shift registers in this mode, but not the buffer. We feed one to the LAT line, and the contents of the shift register is transferred to the buffer immediately after each pulse on the CLK line. And after each rewrite, we blink several times with an LED through OE in order to read the results with a phototransistor and add up two batteries, as described above. Finally, after determining whether the LED is blocked, we write the result to the framebuffer provided in the library.

When the entire photogram has been scanned, it will be sufficient to enable the interrupts again - and the picture from the framebuffer will be recorded in the matrix in the standard way and displayed, after which it will remain there until the beginning of the next scan.

Video:

Source: https://habr.com/ru/post/454462/


All Articles