As the past few projects have been quite frivolous gadgets, this time I'm going to do something practical. It turns out this was actually one of the quicker projects I've done and makes a decent weekend project for anyone looking to make a quick upgrade to their cars audio system.
My car as an auxiliary audio input for connecting MP3 players etc. For this I purchased a bluetooth speaker adapter on Ebay for about a tenner.
It's a great device to connecting my phone for sat-nav, music etc, but there's a small annoyance in the fact that after getting in the car, it requires me to press and hold the power button for about 5 seconds before it'll turn on and connect to my phone. It's a bit of a first-world problem, granted, but it's kinda irritating, so I've been thinking about how to solve it.
Ideally, it should function like a built-in bluetooth adapter does in many new cars - as soon as the car is powered on, the bluetooth is powered on and connects to the phone.
After some experimenting with various approaches - microcontroller delays, 555 timers, I found the most functional circuit was a simple capacitor delay circuit, combined with a transistor NOT gate & optocoupler, so that the optocoupler is active, effectively holding down the adapter's power button, for 5 seconds, then switched off until the circuit loses power.
A rough schematic of the circuit I used
The completed circuit on top of the bluetooth adapter
Inside the bluetooth adapter.
Powering the circuit was simple enough - I already have a car 'cigarette lighter' to USB adapter with 2 USB ports - one powers the bluetooth adapter, and it powers on with the car ignition, so I added a USB plug to the timer circuit and used that.
Finally, I didn't want to leave exposed wires or circuit boards visible in the car - knowing my luck some paranoid idiot would freak and call the bomb squad or something, so I 3D printed a simple box enclosure which houses the adapter and the circuit nicely, the box itself nestling neatly in the centre console of my car.
The finished adapter in it's 3D printed box, ready to put in the car
One of the upsides to creating projects for other people, such as the swear jar, is that it often leads to conversation about other ideas, and becomes a great source of other projects.
A lunchtime conversation with a colleague yielded the idea of a laser tripwire, which could be used around the office to trigger practical jokes, use as a 'boss switch' etc.
The idea of laser tripwires is a bit of an old spy-movie cliche, and for practical use a passive IR sensor would be both easier and more useful, but there's a certain novelty aspect to using a laser that I couldn't resist.
In addition, I've set a couple of additional challenges for myself:
I'm making this a 'speed-run' build, because I'm getting frustrated at the amount of time it's taking for me to complete projects at the moment.
Only use items I already have lying around. My junk bin is full of half-assembled boards and off-cuts of other projects, and I'd like to get rid of them, so what better way than to actually make use of them.
Apologies for this post being text-heavy. The full writeup is below, or if you're impatient, here's a short demo of the tripwire working.
Day 1 (Monday Evening)
I found an old laser pen as the base, the metal case of it makes it difficult to get into, but I managed to hook in a couple of wires to the battery compartment (it runs on 3v). As I couldn't reach the power button to wire across it, I opted for a low-tech tape solution to just hold the button down. Unfortunately this wasn't strong enough, so I wedged the laser pointer in a copper pipe t-junction that was in the junk bin.
For the receiver of the tripwire, I'm using a small light-dependent resistor (LDR) module. Back when I started with electronics, I created simple screw-terminal breakout boards of various components to aid rapid prototyping - there's 3 terminals, Vcc, LDR output, and ground (via a 10K resistor). To help filter light, I found a red Tic-Tac box, which should filter out most ambient light, but allow the lasers light to shine through.
To threshold the LDR output, I created another low-battery circuit as I've used before in the pedal-keyboard project. This allows for the sensitivity of the receiver to be adjusted, and a digital output to be triggered once the threshold is crossed. I found part of a board which contained the transistors that this circuit would need, and just required some jumping of wires. The resistors were recycled from junk-bin ones which had their legs snapped off.
After applying copious amounts of hot glue to hold it all together in an old business card box, the receiver circuit did work for a brief period, before one of the wires snapped. Hopefully tomorrow I'll only need to re-solder a those wires to finish that circuit, then I can move onto setting up the laser and reflector.
Rough diagram of how this thing should work...
Day 2 (Tuesday Evening)
Fixed the snapped wire from yesterday, & tested the receiver circuit. The next stage is to make it do something useful. I found an old wireless doorbell which I can repurpose.
The transmitter PCB
Transmitter button & receiver PCB
The receiver can trigger the 'button' part of the bell, which will then notify the 'bell' which I'll convert into a handheld device to notify the user of the detector being activated.
The transmitter being tested before putting together.
Days 3 & 4 (Sat and Sun)
Wired in a relay to control the transmitter, and worked on how to power the circuit. As space is limited, I've used a 9V battery, running through a TS7805
regulator to provide 5V to power the detector circuit, and 2 diodes in series to drop the power to approx 3V for the laser pen. The doorbell transmitter runs of 12V, but for convenience I've opted to just power that from it's own battery, as they have quite a long life anyway.
Also rewired the doorbell receiver to a vibration motor from an old Playstation controller, and wired a AA battery holder in place of the original D cell ones. This should result in a pocket-size receiver that vibrates when the laser beam is broken.
The receiver - battery pack on reverse.
A fortnight later....
Day 5 (Sat)
Some bad planning on my part meant that the output signal from the laser receiver was the inverse of what was needed - so effectively the doorbell component was triggered whenever the laser wasn't broken. Not very useful.
Created a not-gate with a simple transistor and wired that in place, however the resulting current was not enough to trigger the relay, so I added another transistor to amplify the not-gates output.
In the end, the whole project took about 3 weeks, but only about 6 days where I was actually working on it. It's a complete bodge, and hideously impractical, but was a nice challenge and works surprisingly better than expected.
The finished product, receiver (left) and laser detector (right)
Recently at work, management instituted a ‘Swear Jar’ system, to try and limit the use of profanity in the office.
Personally, I really have no issue with swearing - words are just words, but many people don’t share that view, so I understand why they did it.
The problem for me is that now, whenever someone swears, there’s a chorus of people shouting “Swear Jar!” at the person who swore. This, to me, is far more annoying than the swearing ever was.
It give me an idea though. What if the phrase “Swear Jar”, was taken more literally - a jar which swears at you when you put money in?
So, yeah, that’s the flimsy premise of this project. Read on for the full write up, or just watch the video of it in action below. (It should really go without saying that the language in the video may be unsuitable for some people..)
The Jar
As a base, I picked up one of those basic coin-counting money boxes often found that those ‘gadget shops’ which tend to open up in shopping centers selling a bunch of battery-operated plastic junk for a few weeks before they inevitably fail.
The coin mechanism is nothing special, essentially a slider which completes connections at different points to detect different coin values. there's not really anything else of value in the circuitry, it's all hidden behind epoxy blobs, so I scrapped everything else.
Audio
To provide the audio, I’m using an old MP3 player that I had in my junk bin - it’s essentially a 512MB memory stick with three control buttons and a headphone jack.
I enlisted a friend's help in trawling through movie clips on YouTube to get audio clips of profane movie quotes (this is where the previous post came from). The end result being a bunch of clips, all 3 seconds in length.
I wired up a small speaker from the junk bin. Fortunately the internal amplifier in the MP3 player was powerful enough to drive the speaker directly - as it's originally designed just for headphones, I thought it might not have sufficient power.
Controller
As this is just a novelty project, and I wanted to get it done and in the office before the swear jar idea was forgotten about, so I didn't really have time to delve too deeply into interfacing with the MP3 players circuitry. I opted to simply use a microcontroller to imitate human interaction. Conveniently, all the functionality I need from the MP3 player is obtained from just one button.
I opted for an ATTiny2313, using the arduino cores for convenience, and a relay to toggle the MP3 players button. Source code is below.
Power
Another complexity with this project is although the MP3 player doubles as a USB disk, powering it via the USB port only allows it to be used as a memory stick, and disables the MP3 playback functionality. Therefore the only other way to power the device is via it's AAA battery slot, so I required 2 power rails - 5v to drive the microcontroller, and 1.5v to power the MP3 player. This was achieved by using a 7805 to arrive at 5v for the micro, then using that 5v fed into an LM317 to provide 1.5 volts for the MP3 player. The main power input is 9v, which was originally intended to come from a battery, but at the last minute swapped for a wall supply (because I couldn't find a battery)
Block Diagram
The below shows how the different components fit together. As this is a frivolous novelty project, I'm not going to put together a full KiCad schematic - the most complex bit was the TS7805 and LM317 circuit, but there's plenty of existing documentation for those online already.
Timing is everything
The problem that quickly became
evident is that the microcontroller has no feedback from the MP3 player,
so cannot tell if a clip is playing, or even if the MP3 player is
switched on. This is why the audio clips needed to all be the same
length. There is also the issue of switching the MP3 player on, which requires a long press of the button. This is addressed in the setup function of the following code.
The MP3 player also has an auto switch-off function that causes it to turn itself off after a short period of time. This means that if no money is put in the swear jar for a while, the next time someone does, nothing happens, and requires the power to be cycled to reboot the whole thing.
The timing requirements are far too precise - even though all the audio clips used were 3 seconds, over time the slightest variances would add up, causing the microcontroller to lose sync with the audio.
So, I'm finally back after quite a long haitus to focus on my day job and studies. This post originated as a request from a friend who wanted to know how to extract snippets of audio from Youtube videos.
With this method the audio can come from any source that is playable in VLC (so, pretty much anything), but for the sake of this example I'm going to use Youtube, as that was the original request.
Step 1 - VideoDownloadHelper
On Firefox there's a plugin called VideoDownloadHelper which makes it easy to save videos from Youtube locally. If you use a different browser there's probably a similar plugin available.
Go to the Youtube page with the video that you want to save. VDH will auto detect the media and the toolbar button will light up.
Select the file - often there's quality options, usually it's best to just select medium. Save the file.
Step 2 - VLC
In VLC, go to File, Convert/Save, select the file, and click Convert.
In the dialog box, select Convert, and under Profile, select the output format that you require, and supply a destination file. Once that’s done, click Start. Wait for the progress bar to complete, and your output file will be done.
Step 3 - Audacity
Final step is to open that audio file in Audacity, play the audio to find the segment you want in the wave form.
Then select the section (just click and drag), then use the trim option (see icon).
The trim icon
Repeat the process until the desired segment of audio is isolated, then go to File, Export As, then export the file to the chosen format.
Tiny Core Linux is a lightweight Linux distribution designed for Live CD usage. Its low system requirements and small footprint also make it a good candidate for reviving older computers or as a base for building virtual machine appliances.
Unfortunately the remaster tool it includes, which is meant to allow for custom Live CDs to be created with chosen software pre-installed, seems to be buggy, and continually failed when I tried using it, so this is the alternative way I found to remaster TCL.
Step 1 Create a basic virtual machine and boot with the TCL Live CD. I used the CorePlus-current.iso, which has some extra software on there, but is still sub 100MB.
Once it's booted to the desktop select TC Install.
Select USB-HDD, whole disk and 'sda' options on the first screen.
Click through the next two screens (formatting options and boot options)
On the install type I checked the Installer Application option as I might need it in my intended application later, but it's optional.
Click through to the next screen where you're selected options will be repeated back to you, and select Proceed.
When it's done installing, shutdown the VM, remove the Live CD image and restart, so that it boots from the HD.
Step 2
Go to apps, and install the software that you require. In my case I installed Open JDK and Filezilla. (Filezilla also requires libiconv to be installed)
Reboot using the TC Exit options (from the menu go to Logout). The backup options there will essentially create a blank mydata.tgz file structure for you to use later.
Once rebooted, copy the /mnt/sda/tce1 folder off the VM to the host system/memory stick whatever (As I installed filezilla I FTP'd it to another server on my network.)
Step 3 (Optional)
On the host system, edit the mydata.tgz that you copied over, and add in any necessary files that you want on the Live CD. Thanks to the reboot that you did in step 2, mydata.tgz will have a basic file structure in place, that maps to the home and opt directories of the live CD. Also it puts in a couple of SH scripts, bootlocal.sh and shutdown.sh - these handle things that you want to execute on boot and shutdown respectively, edit those if you need to. Step 4
Use an ISO editor (I used ISO Master).
Open the LiveCD, and navigate to it's 'cde' directory
Copy your mydata.tgz to the ISO, and replace its onboot.lst, and 'optional' directory with your own.
Navigate back to the ISOs /boot/isolinux directory and edit the isolinux.cfg file.
Find the line
TIMEOUT 600
This line causes it to sit on the bootloader screen for 60 seconds, unless the user selects and option.
I want my live CD to boot without user interaction, and that delay is redundant, so I edited it to
TIMEOUT 10
which allows a 1 second delay before continuing to boot the default option.
Save the edited ISO. To test, setup a blank VM like you did in step 1, and select the edited ISO as the boot medium. TCL should load, with your apps and files already there.
My interest in electronics initially started as a result of PC modding back in the late 90s/early 2000s. Back then, most desktop computers were typical beige boxes - it was all about the internal hardware, not the design of the system itself, and it fell to the users to make then any more interesting than that.
A common mod was to install a LCD screen into the front of the desktop to display things such as system stats (CPU, Memory, temperature), notifications (Email/MSN/ICQ!) or the currently playing track on Winamp.
My old desktop PC has long since been retired, but I still have the LCD that I used, and now I've found an excuse to use it again.
Nostalgia aside, I have a project underway that is going to require a headless Raspberry Pi. While it's easy enough to SSH into the Pi and get to a terminal from another computer, it would also be handy to have at-a-glance stats available.
Fortunately, there's a way to connect a HD44780 LCD (standard text one like mine) to the Pi, using the standard GPIO pins, and leaving the serial pins free (which I'll need for another part of the project).
The thing to be wary of when looking for instructions on connecting one of these displays to a Raspberry Pi is that there are many 'LCD backpacks' and specially designed accessories out there. I'm not using any of those, simply the Pi, the LCD, and a potentiometer to adjust contrast on the display.
Adafruits wiring guide is a good start. While it's aimed at 16x2 displays, it does apply to those of other sizes (the one I'm using is 4x20. They keep referencing their 'Pi Cobbler', though this is simply a breakout board they sell, and it's easy enough to map to the standard Pi pins.
A couple of points worth reiterating - the GPIO pins are designed for 3.3v operation, but the LCD for 5v. To avoid 5v being sent to the GPIO, connect the RW pin of the LCD to ground. Also worth noting is the difference between LED and EL backlight. EL has a higher current draw, so trying to power it from the Pi might overload it (LED however is fine). The displays can operate just fine without the backlight, so it's optional anyway. Mine is EL, but I don't really need it, so just left it unconnected.
I was relieved to see that LCDproc is still around. This was the software I used back with my old desktop, so I chose to stick with this instead of the Python solution Adafruit suggest. The pins that they recommend using are slightly different, but can be adjusted in the LCDproc config.
To install LCDproc on the Pi, run
sudo apt-get install lcdproc
Open the config file
sudo nano /etc/LCDd.conf
find the line
Driver=curses
and replace with
Driver=hd44780
Find (Ctrl+W) the [hd44780] section and change the ConnectionType line to
ConnectionType=rpi
Underneath add the pin mappings in the format shown below
D7=18 D6=23 D5=24 D4=25 EN=8 RS=7
Even though there is a driver file (hd44780.so) in the driver path, it doesn't seem to work.
Some Google searching found someone else with a similar issue and a replacement driver file, see steps 4 through 10 on there. (though note there's some differences in the rest of their setup to mine, so beware.)
Once that's done, restart LCDd with
sudo service LCDd restart
and you should see some text on your LCD!
The default LCDProc screen - the ribbon cable at top left connects to the Pi GPIO.
The small PCB in the top right is a 3.3v to 5v level converter that is to be used for a different project.
This new app is an update to my previous Bluetooth Macro Input app. Unfortunately, for technical reasons, I could not issue this as an update to the existing app.
The new version focuses more on the voice recognition and transcription features of the app,
Now any macros you store in the Macros subfolder can be selected by voice. For example, if you store your macros in
<DEVICE STORAGE>/BluetoothMacroFiles/
and have a macro called
<DEVICE STORAGE>/BluetoothMacroFiles/Macros/Hello world.txt
Then the voice command "Hello World" can be used to load and play back that macro.
Usage
Usage guide for the original file-based macro system can be found here.
Previous update notes are available here.
Requirements Changes
Companion hardware is still required, see the original post for details.
The minimum required version of android is Honeycomb (Android 3.0)