A place for Stuff

  • Home
  • About
  • Contact
  • Arduino Bits’n Pieces
  • Departments
    • Arduino
    • Uncategorized
  • Subscribe via RSS

Whellie good

February 15th, 2010  |  Published in Uncategorized

Arduino + Ethernet shield + XML-RPC + Python

November 5th, 2009  |  Published in Arduino  |  2 Comments

The Problem: In the middle of an exhibition space visitors are encouraged to play a piano.  At the end of the gallery a screen and speakers blare to the music of Tiny Tim.  The visitor at the piano should be able to mute the audio from the piano.  Technical limitations.  There is no way to run cables from the piano any distance but there is power in a floor pit.  The AV at the end of the gallery is run by a Mac Mini buried in the floor.

BTW this is currently installed in the Martin Sharp exhibition at the Museum of Sydney in Sydney, Australia.

31102009568

The Solution. Button -> Arduino with ethernet shield -> ethernet over power -> XML-RPC -> Python -> apple script.

I already had some ethernet over power devices so getting one ethernet shield was cheeper than Xbee or Wi-fi.

Hardware

Basically just a box with a button and an arduino and ethernet shield.  I modified a black cat5 cable to also do power over ethernet so I only had to have one cable going from the box to the floor.

30102009565

Power. I discovered right at the last minute that the arduino with ethernet shield is way more fussy than lots of other projects.  A 9 or 12 volt supply along with the extra draw from the ethernet shield makes for an overloaded power regulator.  When I finally figured out what the problem was a 7.5 volt power supply came to the rescue.

Software

On the ardunio side I didn’t have time for writing a XML-RPC library or anything fancy so I just manually created the one call I needed with basic print statements. You will need to manually calculate your content-length value if you intend to modify.


#include <Ethernet.h>

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte ip[] = { blah, blah, blah, blah };
byte server[] = { blah, blah, blah, blah };

int button_pin = 3;
int buttonState = 0;
int val1;
int val2;

Client client(server, 8888);

void setup()
{
  Serial.begin(9600);
  pinMode(button_pin, INPUT);
}

void muteaudio() {
  Ethernet.begin(mac, ip);
  Serial.println("connecting...");
  if (client.connect()) {
    Serial.println("connected");
    client.println("POST /RPC2 HTTP/1.0");
    client.println("User-Agent: Arduino");
    client.println("Host: blah.blah.blah.blah");
    client.println("Content-Type: text/xml");
    client.println("Content-length: 83");
    client.println("<?xml version=\"1.0\"?>");
    client.println("<methodCall>");
    client.println("   <methodName>doMute</methodName>");
    client.println("</methodCall>");
    client.println("");
    client.println("");
    client.println("");
    client.println("");
    client.println("");
    client.println("");
    client.println("");
    client.println("");
    client.println("");
    client.println("");
    client.println("");
  } else {
    Serial.println("connection failed");
  }

  client.stop();
}

void loop()
{

// Ethernet Feedback
  if (client.available()) {
    char c = client.read();
    Serial.print(c);
  }

 // Button 

   val1 = digitalRead(button_pin);
   delay(10);
    val2 = digitalRead(button_pin);
    if ( val1 == val2){
  	if (val1 != buttonState){ // state has changed
  		if (val1 == 1 and buttonState == 0){
                        Serial.print("Muting Audio");
                        muteaudio();
  		}
  	}
  	buttonState = val1 ;
  }

}

The empty carriage returns are something I accidentally discovered while testing with telnet that makes the python XMLRPC server accept the RPC request.  I don’t know why, but it works.

The python script is pretty basic and just takes the request and writes an applescript command to the shell to switch the audio on and off.

# import modules
import SimpleXMLRPCServer
import subprocess

global toggle
toggle = 1

#The server object
class button:
	def doMute(self):
		global toggle
		if toggle == 0 :
			cl = 'osascript -e \"set volume 0\"'
			print cl
			subprocess.Popen(cl, shell=True)
			toggle = 1
		elif toggle == 1:
			cl = 'osascript -e \"set volume 10\"'
			print cl
			subprocess.Popen(cl, shell=True)
			toggle = 0
		return "Done"

button_object = button()
server = SimpleXMLRPCServer.SimpleXMLRPCServer(("bla.bla.bla.bla", 8888))
server.register_instance(button_object)
#Go into the main listener loop
print "Listening on port 8888"
server.serve_forever()

IR receiver hacking

July 10th, 2009  |  Published in Arduino

Ive been working on IR reception to an Arduino for a work project. I’ve been using a Jaycar receiver I had laying around from an unbuilt kit. I found some promising code online. It was kinda working but not really. After a couple of hours of trying different thing’s trying to problem solve the situation I discovered that it was a power problem. Putting a 100uf capacitor over the power line made everything work. The Jaycar part doesn’t need or work with the resistors between the ardunino and the IR receiver as mentioned in the blog post using the Radio Shack receiver.

http://www.rtfa.net/2009/01/02/arduino-ir-remote-control-more-advanced
http://www.jaycar.com.au/productView.asp?ID=ZD1952&keywords=receiver&form=KEYWORD

I’m also using a Sony remote but not the same one as the blog post.

Then after as I was about to finish up I turned off a work light and the IR receiver starts responding to background noise. hmm should be able to solve that one in software.

Geo Dome Projection, Peats Ridge 2008

May 11th, 2009  |  Published in Uncategorized

Here is a bit of documentation shot from video control. It’s always difficult to document your own work when performing.

Dome Projection Peats Ridge Festival 2008 from Justin Maynard on Vimeo.

Rocket Car Day 11

May 4th, 2009  |  Published in Uncategorized

Had heaps on fun at Rocket Car Day 11, We shot an add for the Dorito competition for a bit of fun.

p5031694_small1
03052009426_small1
p5031701_small

Twitter etc

April 2nd, 2009  |  Published in Uncategorized

I’ve been toying with twitter, my user name is justinatomatic if you want to follow my tweets. I’ve also been toying with thumbwhere.com.

Kaylee Claire Maynard

April 2nd, 2009  |  Published in Uncategorized

It’s all a bit yay. Welcome to the world Kaylee. Born Friday the 27th at 7:44 PM 8 Pounds 54 cm. kaylee

Arduino Bits’n Pieces

January 15th, 2009  |  Published in Arduino

Check out the new page up. I’m beginning to publish my arduino adventures.

Its just a start. I hope to expand on a few of the projects and provide code where I think people will care.

Design

July 26th, 2008  |  Published in Uncategorized

Its just a standard wordpress theme. Admittedly inspired by my mate Geoff over at sunheartcowfork.com. I might spice it up sometime but then again I’m still getting over a dot com boom aversion to HTML/CSS

Hello world!

July 25th, 2008  |  Published in Uncategorized

Got to start somewhere.

Previously


Nov 5, 2009
Arduino + Ethernet shield + XML-RPC + Python

by admin | Read | 2 Comments

The Problem: In the middle of an exhibition space visitors are encouraged to play a piano.  At the end of the gallery a screen and speakers blare to the music of Tiny Tim.  The visitor at the piano should be able to mute the audio from the piano.  Technical limitations.  There is no way to [...]


Jul 10, 2009
IR receiver hacking

by admin | Read | Comments Off

Ive been working on IR reception to an Arduino for a work project. I’ve been using a Jaycar receiver I had laying around from an unbuilt kit. I found some promising code online. It was kinda working but not really. After a couple of hours of trying different thing’s trying to problem solve the situation [...]


May 11, 2009
Geo Dome Projection, Peats Ridge 2008

by admin | Read | Comments Off

Here is a bit of documentation shot from video control. It’s always difficult to document your own work when performing. Dome Projection Peats Ridge Festival 2008 from Justin Maynard on Vimeo.


May 4, 2009
Rocket Car Day 11

by admin | Read | Comments Off

Had heaps on fun at Rocket Car Day 11, We shot an add for the Dorito competition for a bit of fun.


Apr 2, 2009
Twitter etc

by admin | Read | Comments Off

I’ve been toying with twitter, my user name is justinatomatic if you want to follow my tweets. I’ve also been toying with thumbwhere.com.


Apr 2, 2009
Kaylee Claire Maynard

by admin | Read | Comments Off

It’s all a bit yay. Welcome to the world Kaylee. Born Friday the 27th at 7:44 PM 8 Pounds 54 cm.

About A place for Stuff

random stuff of questionable relevance

Contributors

  • admin

Popular

  • Arduino + Ethernet shield + XML-RPC + Python
  • Links

    • Native Resolution
      Me in video mode
    • Spark Fun


  • ©2010 A place for Stuff
    Powered by WordPress using the Gridline Lite theme by Graph Paper Press.