Jessica Chang
Created October 17, 2015

HW 5 - Advanced Soldering & Project 1 - Drawing Machine

fumes and broken parts galore..

Work in progress27
HW 5 - Advanced Soldering & Project 1 - Drawing Machine

Story

Read more

Code

Hw5

Java
/* Sweep
 by BARRAGAN <http://barraganstudio.com> 
 This example code is in the public domain.

 modified 8 Nov 2013
 by Scott Fitzgerald
 http://www.arduino.cc/en/Tutorial/Sweep
*/ 

#include <Servo.h> 
 
Servo myservo;  // create servo object to control a servo 
                // twelve servo objects can be created on most boards
 
int pos = 0;    // variable to store the servo position 
 
void setup() 
{ 
  myservo.attach(7);  // attaches the servo on pin 9 to the servo object 
  pinMode(3, OUTPUT);
  pinMode(5, OUTPUT);
  pinMode(6, OUTPUT);
  digitalWrite(3, HIGH);
  digitalWrite(5, HIGH);
  digitalWrite(6, HIGH);
} 
 
void loop() 
{ 
  for(pos = 0; pos <= 180; pos += 1) // goes from 0 degrees to 180 degrees 
  {                                  // in steps of 1 degree 
    myservo.write(pos);              // tell servo to go to position in variable 'pos' 
    delay(10);                       // waits 15ms for the servo to reach the position 
  } 
  for(pos = 180; pos>=0; pos-=1)     // goes from 180 degrees to 0 degrees 
  {                                
    myservo.write(pos);              // tell servo to go to position in variable 'pos' 
    delay(10);                       // waits 15ms for the servo to reach the position 
  } 
//  myservo.detach();
} 

Drawing Robot

Java
I used the program we wrote in class and modified it by adding the pins for the extra motor that I used.
// very simple stepper motor test program
// for L298 type 
// each input controls one output

// Michael Shiloh 10/5/15
// This program is in the public domain 

// my four inputs
// colors represent the color of the stepper 
// motor wire attached to the corresponding 
// output 
const int grey = 4;
const int green = 5;
const int yellow = 6;
const int red = 7;

const int purple = 9;
const int grey2 = 10;
const int white = 11;
const int black = 12;

void setup()  {
  pinMode(grey, OUTPUT);
  pinMode(green, OUTPUT);
  pinMode(yellow, OUTPUT);
  pinMode(red, OUTPUT);
  
  pinMode(purple, OUTPUT);
  pinMode(grey2, OUTPUT);
  pinMode(white, OUTPUT);
  pinMode(black, OUTPUT);
}

void loop() {
    digitalWrite(grey, LOW);
    digitalWrite(green, HIGH);
    digitalWrite(yellow, LOW);
    digitalWrite(red, HIGH);
    
    digitalWrite(purple, LOW);
    digitalWrite(grey2, HIGH);
    digitalWrite(white, LOW);
    digitalWrite(black, HIGH);
    delay(10);
    
    digitalWrite(grey, LOW);
    digitalWrite(green, HIGH);
    digitalWrite(yellow, HIGH);
    digitalWrite(red, LOW);
    
     digitalWrite(purple, LOW);
    digitalWrite(grey2, HIGH);
    digitalWrite(white, HIGH);
    digitalWrite(black, LOW);
    delay(10);
    
    digitalWrite(grey, HIGH);
    digitalWrite(green, LOW);
    digitalWrite(yellow, HIGH);
    digitalWrite(red, LOW);
    
    digitalWrite(purple, HIGH);
    digitalWrite(grey2, LOW);
    digitalWrite(white, HIGH);
    digitalWrite(black, LOW);
    
    delay(10);

    digitalWrite(grey, HIGH);
    digitalWrite(green, LOW);
    digitalWrite(yellow, LOW);
    digitalWrite(red, HIGH);
    
    digitalWrite(purple, HIGH);
    digitalWrite(grey2, LOW);
    digitalWrite(white, LOW);
    digitalWrite(black, HIGH);
    delay(10);
}

Credits

Jessica Chang

Jessica Chang

12 projects • 0 followers
jessmchang.com

Comments