The processes involved when I make stuff: sculpting, programming, electronics, carving, moulding, etc. Mostly puppets, automata, sculpture, occasionally furniture, interactives, food, etc. Usually fairly detailed and image-led. Please reuse any ideas, tips, thoughts and approaches.
Monday, 20 August 2012
Twitr_janus head designs
I can't decide quite what the vibe should be for Twitr_janus. It should be slightly unsettling or distrubing, but not too evil. More like just a tiny bit weird, than downright scary...

Labels:
#rosemarybeetle,
head,
heads,
puppet,
puppets,
twitr_janus
Friday, 17 August 2012
Pimping a Google spreadsheet form, to create a bespoke control form with sliders
Link here to download complete Processing sketch on Github
This expands on the previous post, which explained how to use the RSS feed from a published spreadsheet to extract remote control data from that feed and use it in a Processing sketch.
Here this idea is extended to use a Google form, instead of typing into the sheet. This has the advantage that all the values to be sent can be prepared at once, then the form submitted. It is still a bit clunky, but it does imporve it slightly. A mthod of controlling the inputs to submit data between fixed upper and lower values for both horizontal and vertical position variables is described below.
The values in the fields F2, G2 and H2 are the data that will be used remotely by the sketch. The data in these fields are being constructed from the control character ¬ in E2, and the last instance of a form return from columns B (representing up/down eyeball data), C (representing left/right eyeball data) and D (speech text) for the Twitr_janus puppet.
The Google expression in cell F2 to return the last NUMERIC value of column B is...
=trim(E2&(FILTER( B2:B ; ROW(B2:B)=MAX(FILTER( ROW(B2:B) ; ISNUMBER(B2:B))))))
The Google expression in cell G2 to return the last NUMERIC value of column C is
=trim(E2&FILTER( C2:C ; ROW(C2:C)=MAX(FILTER( ROW(C2:C) ; ISNUMBER(C2:C)))))
and the Google expression in cell H2 that returns the last TEXT value of column D is
=trim(E2&FILTER( D2:D ; ROW(D2:D)=MAX(FILTER( ROW(D2:D) ; ISTEXT(D2:D)))))
The puppet is not yet built, so a surrogate virtual face is being used to react to the data. It is rather basic...
The standard form for the spreadsheet was set up as usual and has text boxes. This is slightly better than direct typing into the sheet, in that the 3 values can be sent in one go. However, it requires the user to have to know the values needed to make the eyeballs move and allows any value to be submitted, which will cause problems.
To get round this, the source code of the form needed to be adjusted. It looked like this:
The post method used here will only work if you are logged in as an editor of the sheet, but if you are logged in the form code can be used on any webpage. This means you can copy it and hack it, then embed on your page.
The main thing to note here was the adjustments to the input controls for the two eyeball data fields.
The original input has the attribute type="text". This is shown on the left astext boxes.
The pimped version on the right (from an iPad screen) uses the attribute type ="range".
Range is an HTML5 feature that displays a slider.
It also allows for min and max attributes to be set, which limit the data entry to between those two values. Just what was needed!
ta-da!
This expands on the previous post, which explained how to use the RSS feed from a published spreadsheet to extract remote control data from that feed and use it in a Processing sketch.
Here this idea is extended to use a Google form, instead of typing into the sheet. This has the advantage that all the values to be sent can be prepared at once, then the form submitted. It is still a bit clunky, but it does imporve it slightly. A mthod of controlling the inputs to submit data between fixed upper and lower values for both horizontal and vertical position variables is described below.
The Google spreadsheet showing form data and control data based on the last form entry
The values in the fields F2, G2 and H2 are the data that will be used remotely by the sketch. The data in these fields are being constructed from the control character ¬ in E2, and the last instance of a form return from columns B (representing up/down eyeball data), C (representing left/right eyeball data) and D (speech text) for the Twitr_janus puppet.
The Google expression in cell F2 to return the last NUMERIC value of column B is...
=trim(E2&(FILTER( B2:B ; ROW(B2:B)=MAX(FILTER( ROW(B2:B) ; ISNUMBER(B2:B))))))
The Google expression in cell G2 to return the last NUMERIC value of column C is
=trim(E2&FILTER( C2:C ; ROW(C2:C)=MAX(FILTER( ROW(C2:C) ; ISNUMBER(C2:C)))))
and the Google expression in cell H2 that returns the last TEXT value of column D is
=trim(E2&FILTER( D2:D ; ROW(D2:D)=MAX(FILTER( ROW(D2:D) ; ISTEXT(D2:D)))))
The puppet is not yet built, so a surrogate virtual face is being used to react to the data. It is rather basic...
The standard form for the spreadsheet was set up as usual and has text boxes. This is slightly better than direct typing into the sheet, in that the 3 values can be sent in one go. However, it requires the user to have to know the values needed to make the eyeballs move and allows any value to be submitted, which will cause problems.
To get round this, the source code of the form needed to be adjusted. It looked like this:
Source code for standard Google form
The post method used here will only work if you are logged in as an editor of the sheet, but if you are logged in the form code can be used on any webpage. This means you can copy it and hack it, then embed on your page.
Source code for the pimped Google form
![]() |
| Original dull ole' Google form |
| Beautiful pimped form with range limited sliders - nice! |
The original input has the attribute type="text". This is shown on the left astext boxes.
The pimped version on the right (from an iPad screen) uses the attribute type ="range".
Range is an HTML5 feature that displays a slider.
It also allows for min and max attributes to be set, which limit the data entry to between those two values. Just what was needed!
ta-da!
Wednesday, 15 August 2012
Remote-control eyeballs: Using remote data from a published Google spreadsheet to position eyes with Processing
Above is shown a simple keyboard controlled Processing sketch in action. The arrow keys are used to position the way the eyes look. Each arrow key increases the value of a position variable for the irises and separately for the pupils of the eyes.
To remote control Twitr_janus' eyeballs, this was extended to send position data in 2 directions based on the values in a published google spreadsheet. The RSS feed is read and parsed by Processing to extract the data, which is used to compare the current horizontal and vertical positions with the target positions received. Processing runs a detection function that detects any difference, and reduces the difference by incrementally adjusting the current position and redrawing the eyes, until it can't detect a difference. A classic cybernetic negative feedback system!
Left published Google spreadsheet. Right, same with eyes.
Initially, so attempts at this went a bit haywire, due to over thinking the script to work out boundaries to stop the irises and pupils doing strange things (left) or leaving the edge of the eyes (right).
This java applet demonstrates the direct keyboard sketch in action. This is freely available to download and copy at http://openprocessing.org/sketch/67233
It requires Java, so won't work on some devices, but if you have a Java plug-in, you can make the eyeballs move with the keyboard arrow keys...
Labels:
#rosemarybeetle,
eyeball,
google spreadsheets,
Processing
Thursday, 9 August 2012
Twitr_janus is now speaking data sent from published google spreadsheet (via RSS feed to Processing)
Twitr_janus' brain can detect more data
I have finally managed to work out how to get Processing to respond to data live from a Google spreadsheet. The effect of this is that I can send separate multiple packets of data to Twitr_janus from a single source, to control multiple functions.This is a significant development, as data can now be sent for different functions such as text to be spoken or positioning information for eyes, or other body movements.
I have made a successful test of sending 3 packets at once to the latest version of the Processing sketch (Twitr_janus' brain), which it can decode. These were:
- A number that could be sent by Processing to the Arduino, to tell it how to position a control servo for an up/down eyeball movement
- A similar number that could be sent by Processing to the Arduino, to tell it how to position a control servo for an left/right eyeball movement
- A text string that was successfully received and converted to speech.
download: mp3
"This is Twitr_janus speaking thoughts from a google spreadsheet"
download: mp3
This method of getting data from my master means I can speak much longer lines, and not worry about stop characters
download: mp3
"Oh yes! and the sending of other data from the same google spreadsheet works. This means my eyeballs could be made to move."
How Processing gets the data from a remote Google spreadsheet via RSS
Setting up the spreadsheet
A Google spreadsheet was set up to hold the test data. This had three data fields for ENTERING data:- eyeballUpDown (the field name says it all really) - data in A2 in the spreadsheet
- eyeballLeftRight - data in B2 in the spreadsheet
- text (this is the piece of text used to make Twitr_janus talk - data in C2 in the spreadsheet
- eyeballUpDown_stop (the same field name with _stop appended) - data in E2 in the spreadsheet
- eyeballLeftRight_stop - data in F2 in the spreadsheet
- text _stop (this is the piece of text used to make Twitr_janus talk - data in G2 in the spreadsheet
This character was there to be used by Processing to know where to parse the data in the RSS feed. The character can be any SINGLE character, but it must be something that is not going to to be present in the RSS feed output or in normal speech.
In this case the following character has been used: ¬
Making the spreadsheet publish to the web automatically and obtaining the RSS url
From the file menu, choose the "Publish to the Web" option. This make the data public as read only. You can still edit the original sheet and control share rights for edit, but the data is now available to use.
The checkbox must be checked for "Automatically republish when changes are made". This will force the RSS feed to refresh when you type in new data.
You then need to get the url for the RSS feed. Select RSS from the "Get a link to the published data" option, and copy the url.
What the RSS data looks like
The output of the RSS feed will be read as a string that looks like this:
How Processing extracts the data from the RSS feed
(You can download the entire Processing sketch for this particular version Twitr_janus on Github: https://github.com/downloads/rosemarybeetle/Twitr-Janus/twitr_janus_processing_control_PC_2.pde)The Processing sketch uses a function called getGssData (). Here it is, with some notes about the data extraction using parsing. I have not explained the rest of the function, nor the variable initialisations.
void getGssData ()
{
// uses Google SpreadSheets API to get public tweets from twitr_janus_eyeballs published spreadsheet
gssTextCheck = gssText;
println ("@@@");
println ("[Start Inside printGSS]");
println ();
String [] texty = loadStrings(gssApiString);
The line above is using the Processing function 'loadStrings'. 'gssApiString' has been initialised earlier with the RSS feed URL (https://spreadsheets.google.com/feeds/list/0AgTXh43j7oFVdDJSaHU1ejFqdVRTZU1ZZ1Fabmt2UXc/od6/public/basic?alt=rss)
and loading the raw XML output as a string into an array (texty[])
String [] texty2 = split (texty[0], '¬'); // pulling out data with stop character
The line above is using the Processing function 'split' to break down the feed text based upon the special stop character '¬'. It is creating an array (texty2[]) which will have 5 values in it, because the feed has four of these characters in it, which are splitting the feed string into 5 sections.
The values are:
- texty2[0] = contents of everything before the '¬' in cell D2
- texty2[1] = contents of everything after that and before the '¬' in cell E2
- texty2[2] = contents of everything after that and before the '¬' in cell F2
- texty2[3] = contents of everything after that and before the '¬' in cell G2
- texty2[4] = contents of everything after the '¬' in cell G2
String [] texty3 = split (texty2[4], '<'); // get rid of trailing text after <
The line above finally gets texty2[4] (= the contents of everything after the '¬' in cell G2) and splits it based on the '<' tag in XML, which is the character that follow the contents of G2. This leaves the text from cell G2 which is set as the variable gssText in the line below:
gssText = texty3[0];
gssTextLength= gssText.length();
The lines below do a similar thing to extract the contents out of E2
// @@@@@@@@@@@@@@@@
String [] texty4 = split (texty2[2], ',');
gssEyeballUpDown = int (texty4 [0]);
print ("gssEyeballUpDown = ");
println (gssEyeballUpDown);
println ();
Finally the lines below do a similar thing to extract the contents out of F2
// @@@@@@@@@@@@@@@@
String [] texty5 = split (texty2[3],',');
gssEyeballLeftRight = int (texty5 [0]);
print ("gssEyeballLeftRight = ");
println (gssEyeballLeftRight);
println ();
// @@@@@@@@@@@@@@@@
//print ("texty= ");
//println (texty);
println ();
//print ("texty2[2]= ");
//println (texty2[2]);
println ();
//print ("texty2[3]= ");
//println (texty2[3]);
println ();
print ("gssText = ");
println (gssText);
println ();
println ();
// following lines return the contents of tweet check (last new tweet)
println ("[End Inside getGSS]");
println ("@@@");
println ();
if (gssText.equals(gssTextCheck)==false)
{
println ("inside GSS checking IF");
print (gssText);
println ("");
print (gssTextCheck);
println ("@");
port.write(gssTextLength);
tts.speak(gssText);
};
}
Advantages of using Google spreadsheets to send data
Although this is a similar method as having Twitr_janus listen for tweets, using a spreadsheet has advantages, mainly because there is much more control over the RSS feed format than there is the Twitter API. This means:- Several fields of data can be changed in a spreadsheet simultaneously, by using multi-cell cut and paste. So if the left/right and up/down position of eyeballs needed to be changed simultaneously, this could be done in one paste action.
- By prefixing the data in control fields with an unusual stop character, the Processing command that is parsing the text, will not get confused by common punctuation used in tweets. Notably commas and "quote marks", are used by the Twitter API as field delimiters, and these cause parsing issues truncating the message unexpectedly. The Google method eliminates this.
- The maximum number of calls in a set time to Google spreadsheet RSS feeds appears to be much higher than Twitter's API. This allows Twitr_janus's brain to check much more frequently (an improvement from about every 28 seconds maximum with Twitter API, to every 5 seconds or faster with the Google feed)
- It is probably possible to write a javascript gadget that will write to Google spreadsheet cells in a more interactive way (such as an onscreen slider that writes values to the cells)
This took a lot of coffee and about 7 hours of brainache...
Labels:
#arduino,
#rosemarybeetle,
google spreadsheets,
parsing RSS,
Processing,
RSS,
twitr_janus,
Twitter API
Monday, 6 August 2012
Turning a Twitter profile picture into a real-life 3d custom figure
Over on Instructables, I have posted the complete how to for making a Twitter avatar image into a 3d figure, using modelling, moulding, casting and hand painting.
Been embargoed for a while, because it was a present for someone leaving work.
I have finally written it up.
www.instructables.com/id/Turning-a-twitter-avatar-into-a-real-life-custom-f/
The full Instructable shows the steps in detail, including:
Modelling in plasticine...
Moulding in silicon latex using simple domestic waste as mould containments...
How to cut out mould sections directly into latex without the need for mould section separators...
Using good old hot-glue as a moulding material...
And finally applying layered finishing with emulsion paint, PVA, marker pen and artists' felt tip pens.
Labels:
#rosemarybeetle,
casting,
felt-tip pen,
hot glue,
hot-glue,
modelling,
mould-making,
moulding,
plasticine,
silicon latext,
Twitter
Sunday, 5 August 2012
A self-contained relay circuit unit
Schematic and circuit unit
Having got the relay circuit to work on the testbed breadboard, it was time to build it into a unit...Here's the schematic and the finished board together.
The relay circuit is very simple. This relay uses a 5V voltage to trigger the switchover. The transistor has no current flowing as default, which means the output power voltage is sent to one connector (middle right block).
Applying a signal voltage HIGH to the input, causes a current to flow in the transistor and therefore through the relay switching coil. This changes the power voltage to the alternate relay output pin.
Earthing
There are two separate circuits in a relay. There is a high current power switched circuit, which here is 12V. There is also a coil circuit that switches this power voltage from one output to another. Here the switch circuit is driven at 5V.The earth of the two relay circuits should be connected or natural differences in voltage levels can cause unexpected problems.
Completed circuit unit
The left hand image shows the circuit in it's final form on the board with connectors. The red indicates power voltages with black as earth.
The left hand connectors are the coil circuit power in, the coil earth and an earth connector for the power circuit linked to the coil earth.
The right hand connectors are for the power supply voltage (top, all red), the power voltage with signal switched on (also all red), and power voltage with signal off (black and red), respectively.
The right hand image shows the underside with connectors and mounting screws.
The top, black connector block is for the signal in.
This unit is now ready to be deployed as required.
Labels:
#arduino,
#rosemarybeetle,
arduino,
relay,
Twitr Janus,
twitr_janus
Sunday, 29 July 2012
Manipulating tweet character count in Arduino to control lip-sync duration
Simplified serial data connection between Processing and Arduino
Detail of the Processing sketch, showing sub-clause of tweetCheck () function which is checking incoming tweets from @twitr_janus. When it detects one, it sends a trigger signal to the Arduino to start jaw movement, then immediately initiates text-to-speech on the text. This will make the jaw move as the text speech audio plays.
Download the complete Processing sketch running on the PC detecting tweets
Download the complete Arduino sketch running on the Arduino board
Download the complete Processing sketch running on the PC detecting tweets
Download the complete Arduino sketch running on the Arduino board
Simple example - triggering an Arduino response to a tweet by sending a flag over the serial port.
This clause checks if it is a new tweet:
if (tweetText.equals(tweethCheck) == false)
"tweetText" is the latest value of last tweet from twitr_janus, "tweetCheck" is the last new tweet.
It is doing two things here. Firstly it is sending a message of value NULL to the serial port (called imaginatively "port") which will send it over to the USB connection to the arduino board. This could be done wirelessly in principle.
port.write("NULL")
The NULL character is converted to 0 when it is transmitted as data over the serial connection. The Arduino will start a jaw movement control signal if it detects a signal of value 0. In the code shown, it is simply turning a PIN on and off 8 times, with a 100ms delay before switching between HIGH and LOW, to give a 200ms period..
Adding logic - using tweet length to control the lip-sync signal duration
Using a simple value is fine for an on-off trigger, but the lip-sync should only occur for the duration of the speech generated by the tweet. This will vary depending on the number of characters in the tweet. This can be obtained using the length() method.
By sending the tweet length (number of characters) instead of a simple trigger, lip-sync logic can be created in the Arduino sketch running on the board, that will cause the lip sync duration to match the speech audio duration.
The Arduino function is called jawChomper ().
"incomingByte" is the tweet length in number of characters
"chompFactor" is a scaling factor that reduces the character length into jaw movement number. This is because when you speak your jaw does not move for every character. It moves based on words, which are groups of characters.
"chompDelay" is the standard duration in milliseconds, of the alternate HIGH and LOW values of the control signal.
"chompRand" is a controlled randomisation factor. This is added, to cause each HIGH or LOW to vary in duration. This is because the code cannot determine word length, so the jaw cannot be synced to the words. Just turning the signal on and off is not good enough. The brain can easily detect a rigidly uniform rhythm and it will jar. Varying the duration of up and down motion is a simple way to trick the brain into thinking the jaw is in sync with the speech, when it is actually just stopping and start in an asymmetrical rhythm.
void jawChomper ()
{
// this function sets jaw bighting rate for
// read the incoming byte:
digitalWrite(13, HIGH);
for (int i = 0; i < (incomingByte/chompFactor); i++) {
// turn the pin on:
digitalWrite(peakPin, HIGH);
delay(chompDelay+random(chompRand));
// turn the pin off:
digitalWrite(peakPin, LOW);
delay(chompDelay+random(chompRand));
}
digitalWrite(13, LOW);
// say what you got:
Serial.print("I received: ");
Serial.print(incomingByte);
Serial.print(incomingByte, DEC);
}
The voltage signal sent from the Arduino (signal pin here is peakPin - pin 6 as it happens) is connected to the base of a transistor with a resistor to supply a signal current. When the pin is HIGH, the transistor will amplify it to a current high enough to trigger the relay and turn on the power to the motor (not shown here).
When the signal goes LOW, the transistor current will stop and turn of the relay.
Labels:
#arduino,
#rosemarybeetle,
arduino,
Processing,
relay,
serial connection,
twitr_janus
Sunday, 22 July 2012
Twitr_janus talks through temporary animatronic jaw
Twitter to speech converter kit list
- Twitter app (here on iPad) to Internet
- Internet to PC running Processing sketch periodically scans for twets and strips message
- Processing converts to spoken output using tts.h text-to-speech library
- Speech played through audio amplifier
- Amplifier secondary speaker output connected to Arduino analog input
- Voltage detection in Arduino triggers output pulses on peaks
- Peaks switch power on and off, from model railway transformer connected to car door actuator motor
- Actuator moves jaw in time to speech peaks
Watch the complete loop from tweet to talking cardboard...
Labels:
#arduino,
#rosemarybeetle,
eyeball,
Processing,
texttospeech
Thursday, 19 July 2012
Mad scientists...
Oscilloscopes
You can't quite earn your mad scientist badge without having one of these babies...
I can't even remember where I obtained this, but it's lovely...
Analogue dials!
I can't even remember where I obtained this, but it's lovely...
Analogue dials!
Labels:
#rosemarybeetle,
electronics,
oscilloscope,
twitr_janus
Subscribe to:
Posts (Atom)




