Making Things Interactive

February 19, 2008

Spinning Color Wheel and Servo Motor

Filed under: 6: More Motion, Tiffany Yang — tyang1 @ 3:19 pm

Originally I wanted to create a drive belt that had numbers on them with a DC motor and rubber band. This would be a game where a solenoid controlled by a button would hit the numbers as they moved by.  The higher the numbers the more points you get.  However, the DC motor with 9V could not take any load.  When I put the rubber band on the motor, it stalled the motor.  Plus I could not get the solenoid to work.  So I moved to a new plan.  I couldn’t think of anything except sticking a color wheel on the DC motor.  The DC motor is controlled by a potentiometer so the faster you turn the potentiometer, the more merging of colors you get.  Since we had to control two things, I decided to control a servo motor.  I could not think of anything cool to do with the servo motor so all I ended up with is a spinning color wheel and servo motor.  The servo motor on its own works well but with the DC motor, the servo motor’s movement is a bit jerky.  I am guessing it is from the noise of the DC motor.         

int motPin = 9;                                   // sets base of motor transistor to PWM 9
int potPin = 0;                                   // sets potentiometer to analog 0
int potValue = 0;                                 // value returned from the potentiometer

int servoPin = 3;                                 // sets servo control pin to PWM 3
int angle;
int pulseWidth;                                   // amount to pulse the servo

void servoPulse(int servoPin, int angle) {        // creating a subroutine
  pulseWidth = (angle * 9) + 300;                 //
  digitalWrite(servoPin, HIGH);                   // turn servo on
  delayMicroseconds(pulseWidth);                  // length of pulse sets the motor position
  digitalWrite(servoPin, LOW);                    // turn servo off
  delay(20);
}

  void setup() {
    pinMode(motPin, OUTPUT);                        // sets motor transistor pin as output
    pinMode(potPin, INPUT);                         // sets potentiometer pin as input
    pinMode(servoPin, OUTPUT);                      // sets servo transistor pin as output
  }

  void loop() {
    potValue = analogRead(potPin) / 4;             // read potentiometer, convert to 0 - 255
    analogWrite(9, potValue);                      // use potentiometer to control motor

    for (angle = 0; angle <=180; angle++) {        // for eaching angle from 0 to 180...
      servoPulse(servoPin, angle);                 // call subroutine
    }
    delay(1000);
}

   

Rotational Forms

Filed under: 6: More Motion, Assignments, Nadeem Haidary — nhaidary @ 2:09 pm

I’m using the potentiometer to control a DC motor. I made this as a tool to experiment with rotational forms. You can put a profile on the disc and the motor will spin it to give the illusion of a 3-dimensional form. I was looking at how fast the disc needs to be spinning to create the illusion. I was trying to see how fast the disc needs to be moving for an LED to look stable even though it is actually only seen once per revolution (through the hole).

I am having problems with the power to the motor dying periodically if I crank it up high. I reverted to thick paper after experimenting with foamcore-but the motor is not powerful enough to spin it quickly.


/*
ROTATIONAL FORM
by Nadeem Haidary

with help from ITP Physical Computing tutorials
*/

int transistorPin = 9;              // connected to the base of the transistor
int transistorValue = 180;          // initial value for motor speed (through transistor)

int potentiometerValue = 0;         // the value returned from the potentiometer
int potentiometerPin = 0;           // the analog pin reading the potentiometer
int motorSpeed = 0;

//-------------------------------------------------------------------

void setup() {
pinMode(transistorPin, OUTPUT);   // Set transistor pin as an output pin
Serial.begin(9600);
}

//-------------------------------------------------------------------

void loop() {

//-----DC MOTOR-----
potentiometerValue = analogRead(potentiometerPin);     // read the analog input
motorSpeed = potentiometerValue/4;                     // converts the potentiometer value (0-1023)
// to a range between 0 - 255 for the motor
transistorValue = motorSpeed;                           // Transfer windspeed to motor
Serial.println(transistorValue);
analogWrite(9, transistorValue);                       // Turn the DC motor on

}

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();
}

Solenoid/Servo Target Shooter

Filed under: 6: More Motion, Assignments, Christopher Bridgman — cbridgma @ 2:00 am

So, for this assignment, i wanted to create a target shooting device out of the solenoid so it would hit a target on the servo motor. i guess this was my interpretation of making the components do something. So here it finally is. This was done by using a simple tilt switch to fire the solenoid to try and hit the servo motor which operated off a simple time delay. However, after hooking all of this stuff up together, the sensor responded very slowly and im not sure why. It made it hard to actually hit the target. But anyways, here is the video.


int statusPin = 13;                // LED connected to digital pin 13
int switchPin = 6;                 // Gravity switch connected to pin 6
int servoPin = 11;                 //servo connected to pin 11
int solenoid = 2;                 //solenoid connected to pin 2
int val;

void setup()                    // run once, when the sketch starts
{
  pinMode(statusPin, OUTPUT);      // sets the digital pin as output
  pinMode(servoPin, OUTPUT);       //sets the analog pin as output
  pinMode(solenoid, OUTPUT);       //sets the digital pin as output
  pinMode(switchPin, INPUT);       //sets the digital pin as input
  Serial.begin(9600); 
}

void loop()                     // run over and over again
{
  val = digitalRead(switchPin);

  Serial.print("Value: ");
  Serial.println(val);   

  analogWrite(servoPin,16); 
  delay(1000);
  analogWrite(servoPin,96);
  delay(1000);
 
  if (val == 1)
  {
      digitalWrite(solenoid,HIGH);
      digitalWrite(statusPin,HIGH);
    }
  if (val == 0)
  {
    digitalWrite(solenoid,LOW);
    digitalWrite(statusPin, LOW);
  }
}

tilt sensor servo motor

Filed under: 5: Making Motion, Assignments, Christopher Bridgman — cbridgma @ 1:44 am

so, i guess this is a continuation of the making motion assignment. in my first attempt at this making motion, i tried using a simple button switch which when activated, sent a power surge into my usb port. me and a couple other students tried again to get a solenoid working, but we think that it is trying to send power into the arduino, not ground, and thus not working. so to complete the making motion assignment, i used a tilt sensor to control where the servo motor goes to. the servo motor goes to a certain position when the tilt sensor is HIGH, and to another position when the sensor is LOW.

int statusPin = 13;                // LED connected to digital pin 13
int switchPin = 6;                 // Gravity switch connected to pin 6
int servoPin = 11;                 //servo connected to pin 11
int val;

void setup()                    // run once, when the sketch starts
{
  pinMode(statusPin, OUTPUT);      // sets the digital pin as output
  pinMode(servoPin, OUTPUT);
  pinMode(switchPin, INPUT);
  Serial.begin(9600);  //sets the digital pin as input
}

void loop()                     // run over and over again
{
  val = digitalRead(switchPin);

  Serial.print("Value: ");
  Serial.println(val);    

  if (val == 1)
  {
      analogWrite(servoPin,16);
      digitalWrite(statusPin,HIGH);
    }
  if (val == 0)
  {
    analogWrite(servoPin,96);
    digitalWrite(statusPin, LOW);
  }
}

Blog at WordPress.com.