Thursday, 4 August 2016

App Update - Bluetooth Macro Input v.1.5


What's New
  • Command support - now send keystrokes for non-character keys - function keys, CTRL, ALT, etc.
  • Bug fix - Bluetooth no longer connects on application load - this prevents some crashing on open. Connection happens when the first bit of text is sent.
Usage
On first run, use the menu button, select settings from the menu and set the options you wish to use.

The most important settings to choose here are "Use Bluetooth Connection" and the bluetooth MAC address for your device. If you do not set a directory for storing your macro files, the default directory is a folder called "BluetoothMacroFiles" under your devices storage location (e.g. /storage/emulated/0/BluetoothMacroFiles).

Once that's done, you can swipe between the two main screens. The first is the voice recognition screen. Tap the button, speak, wait for Google voice recognition to process your speech and a series of possible options are presented.
Tap your chosen option and the device will attempt to send that text through to the bluetooth adapter.

The second screen allows you to select a text file from the menu and send that via bluetooth. The new functionality allows you to define keystrokes for non-character keys - handy for sending commands. For example, a text file containing the following:

{F11}Hello World

will 'press' the F11 key, and then type "Hello World". The extra keys you can type in this manner are:
  • CTRL
  • SHIFT
  • ALT
  • RIGHT_CTRL
  • RIGHT_SHIFT
  • RIGHT_ALT
  • RIGHT_GUI
  • BACKSPACE
  • TAB
  • RETURN
  • ESC
  • INSERT
  • DELETE
  • PAGE_UP
  • PAGE_DOWN
  • HOME
  • END
  • CAPS_LOCK
  • RIGHT
  • LEFT
  • UP
  • DOWN
  • F1
  • F2
  • F3
  • F4
  • F5
  • F6
  • F7
  • F8
  • F9
  • F10
  • F11
  • F12
The arduino sketch adapter I use with the app is detailed here, and the hardware is a Pro Micro with a simple Bluetooth-to-Serial adapter.
In order to get the command functionality working I had to amend the arduino sketch - revised version below:


void setup() {
  Serial1.begin(115200);
  Keyboard.begin();
}

void loop() {
  if (Serial1.available() > 0) {
    byte inChar = Serial1.read();
    Keyboard.write(inChar);
    Serial1.write(inChar);
    delay(10);
  }
}



Support
As with all my apps, it is free, and as such, I am not in a position to offer any kind of official support, so use entirely at your own risk.
If you have any trouble with it, then feel free leave a comment or tweet and I'll try to help as and when I can, but I make no guarantees.

Get it on Google Play

Previous Versions
The original app
First update

Saturday, 28 May 2016

App Update - Soundboard Version 1.5.1


What's New
  • Text-to-speech support added to enable use within the soundboard.
  • Intro screen provides more detail about usage, front screen button auto loads file list on main soundboard.

Usage
 
On open the user will be presented with a two buttons, one will take them to the new Text-to-speech interface, where they can enter text and play it back to inject custom phrases into their soundboard.

The second button will load the regular soundboard as in previous versions, but will automatically load the files into the list (no need to select Load from the options menu).

It is also possible to swipe between the screens as well, so pre-recorded audio can be mixed with TTS-generated speech.

Note, if you swipe across to the soundboard screen from the start of the app, you will need to select Load from the options menu to populate the list.


Support
As with all my apps, it is free, and as such, I am not in a position to offer any kind of official support, so use entirely at your own risk.
If you have any trouble with it, then feel free leave a comment or tweet and I'll try to help as and when I can, but I make no guarantees.


Tuesday, 15 March 2016

New App: Soundboard



My latest Android app is now available on Google Play.

https://play.google.com/store/apps/details?id=com.darkmidnight.soundboard&hl=en_GB




A simple soundboard application. Save some MP3 or OGG files to your phone, load up the app and play them at the touch of a button.

Tap the file names to play

To keep the sound playback levels constant, the app allows you to set a volume level independent of the current volume. On playback, the app sets the volume to that level, plays the sound clip, then returns the volume to it's previous level.

Designed to be used with phones using an adapter such as the one described in my previous post, the app also works well with Xbox Live headsets (Xbox 360), and in theory should work with any device you're capable of connecting your phones audio output to.

The app was built for and tested on an HTC One M9, but should work with any recent flavour of Android.





Usage
Initially, copy the audio files to your devices storage, into a directory called SoundboardFiles.
Open the app, hit the menu button and select load, and you'll get a list of the files as in the first screenshot above.
Go to preferences in the menu and you'll be able to choose whether or not to dynamically set the volume level on playback, and set the volume level if you so wish.

Going back to the main screen, simply tap the filenames to play the file (the app will deal with the volume adjustments automatically.

The volume control menu
If you're struggling to find audio clips to use in the 
See this post for a guide on creating sound clips from YouTube videos and other online sources.

Support
As with my other apps, it is free, with a simple ad banner at the bottom of the main screen.
As such, there is no official support, although I will respond to any comments via this site or twitter as best I can.

Saturday, 5 March 2016

Audio interface for VOIP phones and XBox Live


Update
An unintentional (but useful) outcome of this project is that the connector used in this project is the same as the one used on Xbox 360 headsets, so this same device could be used to inject audio, such as a soundboard, into your in-game chat.

Original post below:
 
I got asked to build another phone audio interface for a colleague who spends a lot of time on the phone and wanted a way to play back pre-recorded audio to save repeating himself.

Unfortunately the existing one I build before is for traditional POTS (plain old telephone system), but the office uses VOIP phones.

I don't have a spare VOIP phone to mess with, so had to look at other options.

The normal headset jack
The phone has a headset port, using a 2.5mm jack socket, and the headsets plug has 3 rings. Given the the headsets themselves consist of just a microphone and earpiece, it stands to reason the pinouts are mic, speaker, and ground.

I don't have the actual pinout for this particular brand of headset, but I have worked with similar ones in the past and typically the tip is the microphone, ring is speaker, and base is ground.



I don't have one of those connectors to hand, but found a stereo headset one from an old hands-free kit. That it has an additional ring connection (for the 2nd audio channel) doesn't matter, it'll effectively join up with ground anyway.

In addition to being able to inject audio into the call, we still need to be able to use the phone normally, so I've used an XBox 360 controllers headphone port to provide a passthrough for the phone headset.


The quick hand-drawn wiring diagram I used. An artist I am not.

Testing this circuit revealed a slight problem, having both the audio source and microphone connected resulted in the microphone becoming inaudibly quiet. In hindsight, this is likely due to the audio source being amplified and the mic not. A simple switch added to the circuit to allow quick switching fixed that.

Adding a simple switch at this point sorted the problem.


The finished adapter in the obligatory tic-tac box


Thursday, 28 January 2016

Copying objects for 3D printing without a 3D scanner


Over the holidays I broke the smoke alarm in my flat. Not the smoke alarm itself as such, but the mount that held it to the ceiling. Judging by the amount of various adhesives that were on the mount, it looks as though a previous occupant had actually broken the mount, but bodged together enough adhesive to hold it tenuously in place until they left.

It still works, thankfully, but it's just hanging from it's power lead.


First of all, take photos of the object against a plain background. Ideally pick a background which contrasts well against the object that you're trying to copy.

  

Editing the image in GIMP/Photoshop
Open the image in a photo editor, and crop any unnecessary bits out the picture.

Create a translucent layer above the current layer, so that you're working on the new layer, but can see through to the photo.
Use the paths tool to trace around the object as best you can, invert the selection and delete the contents. This should remove all the surrounding background bits.

Use the paths tool a few more times to create the cut-outs you require - for example in my case it's removing the centre piece and the screw holes.
Then make the working layer opaque, and fill the outline shape with a colour.

Save and export this image as a PNG.

OpenSCAD is meant to be able to import and extrude PNG files directly, but I've found it to be unreliable, so the below is a workaround that I've been using.

Converting to SVG using Inkscape
Open the edited image into a vector graphics editor, such as Inkscape.

Click on the image, right click and select "Trace Bitmap". Select "Edge Detection". If the image being used is simple enough, you can leave the default values, click OK, and then close the menu.

Drag the bitmap out the way (you can delete it now), and you should be left with an outline of the object. Fill the outline with a colour to make the object solid.


Save this SVG file.

Extruding the file in Blender
Open Blender.

Go to File, Import, Scalable Vector Graphics (SVG). Find the file and select it.
You may have to zoom quite far in to see the imported object.


Select the object and move it slightly,  you'll see a second outline object that gets left behind. Click on the outline object and delete it, you don't need it here, then replace the rest of the object.





Next we need to set the units of the object, so that we can scale it properly. Click the Scene properties tab on the right, and select Metric or Imperial from the units section.

Next, we scale the object.








Press N to bring up the information about the object, and get the dimensions.

Set the X and Y scale here, but for the Z axis we need to extrude the flat image into a 3D object.

To do this, go to the right hand side and select object data, geometry, extrude.

In the case of my project, I added a couple of extra objects to recreate the latches which were broken off the original mount.


Once this is done export to STL and you have a file ready to send to the 3D printer.

Left, the original broken mount, and right, the 3D printed replacement.

Saturday, 26 December 2015

Audio Controlled Christmas Lights

So it's the run up to Christmas, and at work we're having a desk decorating competition. This of course means lights, and an excuse for some colourful, blinky-type projects.

Most supermarkets are selling these battery operated chains of coloured LED lights for a couple of quid. They run off 3 AA batteries (4.5v) and are just static lights.





If you look closely there's actually 3 wires – this is likely because the different colour LEDs have different voltage drops. When I get to dismantling them later we'll know which are on which wire, but my guess is that red and orange are on one line, green and blue on the other. Turns out I was right.

My idea is very simple, wire an transistor onto each line so that they can be controlled independently, then connect a stereo jack to the base, with each channel (left/right) connecting to alternating transistors, so each audio channel will control one strand of lights. The principle is similar to the design I used on the space invaders alarm clock project, but instead of the alternating current being responsible for changing the colour, it'll be the audio channel.


The circuit diagram. The only components I need to add were the transistors, the stereo socket, and a USB cable for power (the resistors were already part of the assembled lights.)


The finished circuit, with the ever-useful TicTacs box enclosure.


The flickering of the lights works, but the frequency is very rapid, which seems to stop the LEDs reaching full brightness. Potentially this could be alleviated by adding capacitors to smooth out the switching, but as the effect varies quite drastically depending on audio source, it's not really an issue. The next challenge is finding a playlist that uses the lights to best effect!




Sunday, 13 December 2015

Car Smoke Machine Pt 3

This is the final part of an on-going series of posts about a project to build and install a smoke machine in my car... for science or something...

If you missed the first two parts, they can be found here

So far we've got an e-Cigarette and an air pump wired together to produce a cloud of smoke. Now what we need is to find a way to control it and install it covertly in my car.

I don't want the trap to spring too early, I need to give them time to get comfortable in the car and get started, for it to be believable.

Also, the motor driver chip will need some logic control, so it makes sense to use a microcontroller to provide the logic and the timings.

As I mentioned in the previous post, left to it's own devices, the eCig's coil gets rather hot, so in order to counter that I wanted the microcontroller to only switch it on in 5 second bursts, then wait 5 seconds for it to cool down.

I used an ATTiny26, for no technical reason other than I have a lot of them spare.


Microcontroller code

 1 #define F_CPU 1000000UL
 2 
 3 #include <avr/io.h>
 4 #include <util/delay.h>
 5 
 6 #define CONTROL_PORT           PORTA
 7 #define output_low(port,pin)   port &= ~(1<<pin)
 8 #define output_high(port,pin)  port |= (1<<pin)
 9 #define delay(a)               _delay_ms(a)
10 #define smokeEnable            PA2
11 #define setInput(ddr,pin)      ddr &= ~(1 << pin)
12 #define isInputHigh(pinr,pin)  pinr & (1<<pin)
13 
14 int isRunning = 0;
15 int secCount = 0;
16 
17 int main(void) {
18     setup();
19     while (1) { loop(); }
20 }
21 
22 void setup() {
23     DDRA = 0xFF;  // all outputs
24     setInput(DDRB, PB6);
25 }
26 
27 void loop() {
28         if (isInputHigh(PINB, PA6)) {
29                 if (!isRunning) {
30                         delay(10000);
31                         output_high(CONTROL_PORT, smokeEnable);
32                         isRunning = 1;
33                 } else {
34                         secCount++;
35                         if (secCount > 5) {
36                                 output_low(CONTROL_PORT, smokeEnable);
37                                 delay(5000);
38                                 secCount = 0;
39                                 output_high(CONTROL_PORT, smokeEnable);
40                         }
41                 }
42         } else {
43                 output_low(CONTROL_PORT, smokeEnable);
44                 isRunning = 0;
45         }
46         delay(1000);
47 }
48 


The finished circuit
Click to enlarge
The Videos
I was hoping to use this to prank as many people as possible, and get some good video footage, but unfortunately only 2 of the videos were really usable. The first, is Craigs "We're all gonna die lads!" reaction, and the second, is Bethany's obliviousness to the cloud of smoke forming around her. Enjoy.