Over the past decade, many have got one two smartphones lying idle, and so is mine. I decided to use a smartphone to control something, for example, a car.
To start, I chose a toy car from Lego. It can move back and forth, turn right and left and has a remote control with IR rays. As a driver for the engine of the machine, the chip LB1836 is used, which has four information inputs. In1, In2 - control the driving motor, In3, In4 - control the steering drive, according to the scheme 0, 0 or 1, 1 - inoperative state. 0, 1 or 1, 0 - the rotation of the engine in one direction or the other.
Logic 0 and 1 at the inputs forms the receiver of infrared rays of the toy when receiving signals from the remote control.
I decided to use the smartphone screen to transmit signals from a smartphone to a typewriter, since other transmission channels are technically complex and expensive to implement. I decided to connect my device to the inputs of the LB1836 chip, which will receive signals from the smartphone.
')
The signal transmission scheme is as follows. The program in the smartphone creates light spots of a given duration on the screen, the device registers them and forms logical 0 and 1 of the same duration at the inputs of the LB1836 without any logical processing, which greatly simplifies the design of the device. That is, I simply replaced the IR-ray receiver with my device.
The device receiving light signals consists of 4 cells. Each cell is an L-3DP3C KGB phototransistor connected to an amplifier on a npn KT315 transistor. Food is taken from a controlled machine. The output, as I said, is connected to the corresponding input of the engine driver. Low-power engines can be powered directly from the exit, but will rotate only in one direction. But there will be four of them!

On the choice of the elements of the device I can say the following. I took the transistors that I have had since ancient times. Phototransistors bought those that were in the store. So, if you want to repeat the scheme, do not waste time searching, use the elements that are available to you. By the way, at the beginning I assembled an LM 324N with four operational amplifiers on a microcircuit. It also works well, but I thought its dimensions were too big.
The device is assembled on cardboard using strips of copper foil and elements of Lego.

Phototransistors are placed at the bottom of light wells with a diameter of 5 mm and a depth of 9 mm, in order to exclude lateral exposure. Metallized films rolled up into a tube are inserted into the light wells, which significantly increases the sensitivity of phototransistors by increasing the light flux.

That turned out such a car.

To develop the program, I took the application BASIC! from Googl Play Market. This application allows you to write programs for Android, create apk files and work with all sensors and devices of your smartphone.
Program listing
DO LET s$=" : " TTS.INIT TTS.SPEAK s$ TTS.STOP STT.LISTEN "" STT.RESULTS theList LIST.SIZE theList, theSize LET kom$="" FOR k = 1 TO theSize LIST.GET theList, k, theText$ IF (theText$="") THEN kom$="" IF (theText$="") THEN kom$="" IF (theText$="") THEN kom$="" IF (theText$="") THEN kom$="" IF (theText$="") THEN kom$="" NEXT k PRINT kom$ GR.OPEN 255, 0, 0, 0 GR.BRIGHTNESS 0.7 GR.ORIENTATION 1 GR.SCREEN w, h a = 255 r = 255 g = 255 b = 255 fill = 1 GR.COLOR a,r,g,b,fill LET wc=0.95*h LET hc=w LET m=36 GR.CLS GR.CIRCLE n5, hc/m*9.5,wc,w/15.6 GR.CIRCLE n4, hc/m*13.5,wc,w/15.6 GR.CIRCLE n3, hc/m*18,wc,w/15.6 GR.CIRCLE n2, hc/m*22.5,wc,w/15.6 GR.CIRCLE n1, hc/m*26.5,wc,w/15.6 FOR i=1 TO 5 GR.HIDE i NEXT i IF (kom$="") THEN GR.SHOW 2 PAUSE 300 GR.HIDE 2 ENDIF IF (kom$="") THEN GR.SHOW 1 PAUSE 300 GR.HIDE 1 ENDIF IF (kom$="") THEN GR.SHOW 2 GR.SHOW 4 PAUSE 300 GR.HIDE 2 GR.HIDE 4 ENDIF IF (kom$="") THEN GR.SHOW 2 GR.SHOW 5 PAUSE 300 GR.HIDE 2 GR.HIDE 5 ENDIF IF (kom$="") THEN GOTO qq GR.BRIGHTNESS 0.1 GR.CLOSE UNTIL 0 ! ONERROR: qq: LET s$=" " TTS.INIT TTS.SPEAK s$ TTS.STOP GR.BRIGHTNESS 0.1 GR.CLOSE END
The program uses voice control as the most appropriate in my case. The TTS object converts text to speech. The STT object converts speech to text. When the STT is working, Wi-Fi must be turned on, because the recorded soundtrack is sent to the server on the Internet, where the recognition result comes from, these are a few words or phrases. The program checks if there is a command in the list, displays the command on the screen and executes it. If the text is not recognized, the program displays a message about it. All this is repeated in an endless loop. The program is terminated by the “stop” command or by pressing the return key. Geometrical dimensions are taken relative to automate binding on different screens with different sizes and resolutions, which is not always the case. The circles that are drawn on the screen are objects and are numbered automatically as they are created.
Team GR.SHOW 2 - means to show the circle, which was created second. His number is in n4. You could write GR.SHOW n4. In the IF line (theText $ = "forward") THEN kom $ = "forward" you will notice the difference in the values of the value in the assignment command - "forward" and "forward." The fact is that the STT stubbornly returns "forward", although there are cases of "forward", then the program does not recognize the command. It was possible to get rid of this, but I did not complicate the program, but simply corrected the spelling when outputting to the screen. There are still failures when recognizing the “left” command. However, perhaps this is a feature of my pronunciation.
Unfortunately, I can not insert a clip showing the work of the program here.
Take a look
here .