Class 08 – Making Things Move

Assignment 2 briefing

Topics

  • Kinetic sculpture
  • Magnetic force
  • Motor
  • Solenoid

Workshop

  • DC motor
  • Servo motor

Reference

 
DC motor experiment
 


 
Arduino with solenoid
 

 

 
Codes

#include <Servo.h>

Servo motor;

void setup()
{
  motor.attach(9);
}

void loop()
{
  for (int pos=0; pos<180; pos++)
  {
    motor.write(pos);
    delay(15);
  }
  for (int pos=180; pos>=1; pos--)
  {
    motor.write(pos);
    delay(15);
  }
}

 

#include <Servo.h>

Servo motor;

void setup()
{
  Serial.begin(9600);
  motor.attach(9);
}

void loop()
{
  if (Serial.available()>0)
  {
    byte x = Serial.read()-48;
    x = constrain(x, 1, 9);
    motor.write(x*18);
  }
  delay(15);
}
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

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

%d bloggers like this: