Making Things Interactive

February 14, 2008

Godzilla Puncher

Filed under: 5: Making Motion,Gaku Sato — ponkotsu @ 4:16 am

Circuitry & Controls:
The pot controls the servo position, on which Ultraman stands projecting his mighty energy beam. When he is aimed directly at the target, the photoresistor picks up the light. When that input exceeds a predefined threshold, a GO signal is sent to the transistor, which activates the solenoid to punch Godzilla right in the face.


Unfortunately, I couldn’t get the solenoid to work. So Godzilla is not punched in the face, and the people of Tokyo will not today be able to escape the always-happening disaster and the credits will not scroll. The solenoid works when it’s just straight 5V to ground, but won’t work when I plug it into a digital pin and output HIGH. The transistor circuit works with a resistor-LED combo in place of the solenoid. I’m not sure what’s going on here. So I’m posting this failure for reference only.

Servo Programming:
The servo control is similar to others’. It’s the only one I’ve come across online, and I’m assuming everyone got it there. The problem I found here was that the potentiometer input only seems to serve as speed control and not position control. I can get the servo to stop (v=0) at a specific pot position but that doesn’t correspond to servo position. I know servos with feedback loops can do position control, but can these not? I don’t know what the control signal is telling the servo to do, so I can’t even figure out the code. Am I doing something wrong here?

Lastly, I still can’t get the code to display below properly. I manually typed in the apostrophes but nothing. I just got another saved draft that crashes IE when I try to edit it. Fantastic. I’ll try to get something working soon…
I’ll be asking what the deal is in class tomorrow.

int PowerPin1 = 13; // power pin – potentiometer
int PowerPin2 = 2; // power pin – photoresistor
int PotPin = 0; // input pin – potentiometer
int PhotoPin = 5; // input pin – photoresistor
int ServoPin = 9; // output pin – servo
int SolePin = 4; // output pin – solenoid

int minPulse = 500;
int maxPulse = 2500;
int pulse = minPulse;
long lastPulse = 0;
int refreshTime = 20;

int punch = 0;

void setup()
pinMode(PowerPin1, OUTPUT);
pinMode(PowerPin2, OUTPUT);
pinMode(PotPin, INPUT); // 0~1000
pinMode(PhotoPin, INPUT); // 800+
pinMode(ServoPin, OUTPUT);
pinMode(SolePin, OUTPUT);
digitalWrite(PowerPin1, HIGH);
digitalWrite(PowerPin2, HIGH);
digitalWrite(ServoPin, LOW);
digitalWrite(SolePin, LOW);

void loop()
pulse = analogRead(PotPin) * 2 – 20 + minPulse;
if(millis() – lastPulse >= refreshTime)
digitalWrite(ServoPin, HIGH);
digitalWrite(ServoPin, LOW);
lastPulse = millis();
if(analogRead(PhotoPin)>800 && punch == 0)
punch = 1;
digitalWrite(SolePin, HIGH);
digitalWrite(SolePin, LOW);
if(analogRead(PhotoPin<800)) {punch = 0;} }[/sourcecode]


1 Comment »

  1. Another [sourcecode] problem — spaces aren’t valid. I fixed yours and I’ll update the instructions.

    Comment by jet — February 14, 2008 @ 9:52 am | Reply

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

Create a free website or blog at

%d bloggers like this: