Making Things Interactive

February 19, 2008

Godzilla Puncher v2

Filed under: 5: Making Motion,Gaku Sato — ponkotsu @ 7:43 am

So my rig still doesn’t work.  I had the solenoid problem last time where the transistor circuit works, the solenoid itself works, but the solenoid/transistor circuit does not work.  We concluded in class that the small transistor I had wasn’t transmitting enough power.  So I figured with my new 90W TIP3055 and trusty 9V batt that I would get some solenoid action but of course, nothing.  I saw Lingshui and Chris had problems with their solenoids, and I’m wondering how anyone got theirs working…

Also, I posted a question regarding servo position control on Sunday that I got no feedback on : (  I’m using #including <Servo.h> but it’s still acting like it’s speed control, just now it’s even more touchy than before.  Input 94deg or 96deg results in the motor rotating in either direction til it pins itself, and 95 gets it to stop.

And my punch-once-only code isn’t working either.  I thought I had it set so that once the photoresistor input exceeds a threshold, the solenoid would activate once, then wouldn’t activate again til the photoresistor input dropped below a lower threshold, but it just keeps activating the solenoid (applying power, at least) when I have the beam focused on the photoresistor without moving anything.

WTF

#include

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

Servo Ultraman; // set servo
long angle = 0; // 95 to stop…

int punch = 0;
int msecond = 0;

void setup()
{
  Serial.begin(9600);
  pinMode(PowerPin1, OUTPUT);
  pinMode(PowerPin2, OUTPUT);
  pinMode(PotPin, INPUT); // 0~1005
  pinMode(PhotoPin, INPUT); // 750+
  pinMode(ServoPin, OUTPUT);
  pinMode(SolePin, OUTPUT);
  digitalWrite(PowerPin1, HIGH);
  digitalWrite(PowerPin2, HIGH);
  digitalWrite(ServoPin, LOW);
  digitalWrite(SolePin, LOW);

Ultraman.attach(ServoPin);
  Ultraman.setMaximumPulse(2400); // 2400 default
  Ultraman.setMinimumPulse(544); // 544 default

Ultraman.write(0);
}

void loop()
{
  angle = analogRead(PotPin);
  angle = angle*180/1005;
  Ultraman.write(angle);
  msecond = millis()/1000;
  if(millis()-msecond*1000 == 0)
  {
  Serial.print(“pot”);
  Serial.print(analogRead(PotPin));
  Serial.print(“:angle”);
  Serial.print(angle);
  Serial.print(” photo”);
  Serial.println(analogRead(PhotoPin));
  }
  if(analogRead(PhotoPin) > 750 && punch == 0)
  {
  Serial.print(“punch!”);
  punch = 1;
  digitalWrite(SolePin, HIGH);
  delay(500);
  digitalWrite(SolePin, LOW);
  }
  if(analogRead(PhotoPin < 600)) {punch = 0;}   Servo::refresh(); }[/sourcecode]

Advertisements

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s

Create a free website or blog at WordPress.com.

%d bloggers like this: