Bloody Lola on Omega 2 or stifle a python on Halloween

  • Tutorial
I never understood this holiday. But the idea was born. Make a creepy doll that will sparkle with its eyes and make creepy sounds.

imageUnder this all turned up a cool children's head (thanks to Anton) and a competition from Onion with the drawing of special whales, which my conscience does not allow me to buy. If so, then the brains of the girl Lola I did on Omega 2, using my work from the previous article.

Anyone who cares how to repeat such a thing, please under the cat.

We will need: two LEDs, a speaker, a 12 volt power supply, a motion sensor (12 volts only), a 3.3 volt power converter, a 5 volt power converter, a simple amplifier (any class D with 3-12 volts) and Omega 2. Optionally, you will need either a flash drive or sd card to expand the disk space.

We open the doll and hot-melt we put the LEDs in the eyes and the speaker in the mouth area. Display wiring in the area of ​​the brain Omega 2. The speaker is soldered to the amplifier, the LEDs are connected to field-effect transistors ... In general, we collect the following scheme.

image

Instead of a 5 volt converter, you can take a dual power supply for 5 and 12 volts, which is closer at hand.

Next, go to setting up the software. If you want to use i2s sound, we put b193 firmware on omega, because i2s doesn’t work further. If not, you can insert a sound card into the USB and then adjust the sound on this guide . If you do like me, then I wrote about working with i2s sound here . We connect to wifi and increase the disk space of omega 2. Everything is in detail in the manual here . After that we perform

opkg update
opkg install alsa-utils mpg123 python pyOnionGpio nano 

Now, our omega is almost able to speak and it remains only to write a Python script for this business. The logic is simple. Motion sensor opens the circuit between the two GPIO. On one, we submit a logical unit when turned on (I have 15 output), the value of the second is read (I use 17 output). When there is 0 (because the PIR sensor has triggered and opened the line), we begin to play terrible sounds and blink LEDs. The rest of the time we are silent, do not touch anyone. Realization of all this looks like this.

import onionGpio
import subprocess
import random
gpioOut = onionGpio.OnionGpio(15)
gpioOut.setOutputDirection(0)
gpioOut.setValue(1)
gpioObj = onionGpio.OnionGpio(17)
status  = gpioObj.setInputDirection()
whileTrue:
#проверяем значение порта
    value = gpioObj.getValue()
#если недалеко человекif int(value)==0:
    	cmd = "fast-gpio pwm 18 " + str(random.randint(5,15)) + " 50"
    	subprocess.call(cmd, shell=True)
    	cmd = "fast-gpio pwm 19 " + str(random.randint(2,10)) + " 50"
    	subprocess.call(cmd, stdout=subprocess.PIPE, shell=True)
    	cmd = "mpg123 -f 256 -C /mnt/sda1/" + str(random.randint(1,6)) + ".mp3"
    	subprocess.call(cmd, shell=True)
#если все спокойноelse:
    	subprocess.call("fast-gpio set 18 0", shell=True)
    	subprocess.call("fast-gpio set 19 0", shell=True)

Files of terrible sounds are added to / mnt / sda1 under the names 1.mp3, 2.mp3 ... I have them 6. and one of them is randomly turned on. Also, the PWM frequency of the Omega 2 outputs is switched on randomly separately under the left and right eyes. It would be possible to use hardware PWM, but here the possible frequency instability is a plus. Then we write two lines to rc.local by executing the commandnano /etc/rc.local

omega2-ctrl gpiomux set i2s i2s
python /mnt/sda1/start.py

As I think you guessed the script I gave above, you need to save it in the / mnt / sda1 directory as start.py .

Next, the last step. Most creative. Makeup. I just asked my wife (cheater) and she did great. Thank you very much!

image

See how it all works with the sound in the video, which is below. In the dark, Lola "The Devourer of male hearts" looks pretty creepy, to be honest. Hope you enjoyed it. Thanks for attention!


And what terrible hand-made you did?

Also popular now: