Drawing Machine – DIY Ink Circles UPDATED

on

Drawing Machine Project in which you are able to control the splatter effect of Ink due to speed, and making a circle.

Despite having some small setbacks, It is up and working!

 

CODE on day of presentation
int motorPin = 9;  // define the pin the motor is connected to
                   // (if you use pin 9,10,11 or 3you can also control speed)
/*
 * setup() – this function runs once when you turn your Arduino on
 * We set the motors pin to be an output (turning the pin high (+5v) or low (ground) (-))
 * rather than an input (checking whether a pin is high or low)
 */

int sensorPin = A0;    // select the input pin for the potentiometer
int sensorValue = 0;  // variable to store the value coming from the sensor

void setup()
{
 pinMode(motorPin, OUTPUT);
}

/*
 * loop() – this function will start after setup finishes and then repeat
 * we call a function called motorOnThenOff()
 */

void loop()                     // run over and over again
{
 
 
 
  // read the value from the sensor:
  sensorValue = analogRead(sensorPin);   
  // turn the ledPin on
if (sensorValue > 512)digitalWrite(motorPin, HIGH); 
 // turn the ledPin off:  
if (sensorValue < 512)digitalWrite(motorPin, LOW);
   
  // stop the program for for <sensorValue> milliseconds:
     
 
 

//motorOnThenOff();
 //motorOnThenOffWithSpeed();
 //motorAcceleration();
{
///*
// * motorOnThenOff() – turns motor on then off
// * (notice this code is identical to the code we used for
// * the blinking LED)
// */
//void motorOnThenOff(){
//  int onTime = 200;  //the number of milliseconds for the motor to turn on for
//  int offTime = 1000; //the number of milliseconds for the motor to turn off for
// 
//  digitalWrite(motorPin, HIGH); // turns the motor On
//  delay(onTime);                // waits for onTime milliseconds
//  digitalWrite(motorPin, LOW);  // turns the motor Off
//  delay(offTime);               // waits for offTime milliseconds
}
/*
 * motorOnThenOffWithSpeed() – turns motor on then off but uses speed values as well
 * (notice this code is identical to the code we used for
 * the blinking LED)
 */
//void motorOnThenOffWithSpeed(){
// 
//  int onSpeed = 200;  // a number between 0 (stopped) and 255 (full speed)
//  int onTime = 6000;  //the number of milliseconds for the motor to turn on for
// 
//  int offSpeed = 50;  // a number between 0 (stopped) and 255 (full speed)
//  int offTime = 10; //the number of milliseconds for the motor to turn off for
// 
//  analogWrite(motorPin, onSpeed);   // turns the motor On
//  delay(onTime);                    // waits for onTime milliseconds
//  analogWrite(motorPin, offSpeed);  // turns the motor Off
//  delay(offTime);                   // waits for offTime milliseconds
}
/*
// * motorAcceleration() – accelerates the motor to full speed then
// * back down to zero
//*/
//void motorAcceleration(){
//  int delayTime = 1; //milliseconds between each speed step
// 
//  //Accelerates the motor
//  for(int i = 0; i < 255; i++){ //goes through each speed from 0 to 255
//    analogWrite(motorPin, i);   //sets the new speed
//    delay(delayTime);           // waits for delayTime milliseconds
//  }
// 
//  //Decelerates the motor
//  for(int i = 255; i >= 0; i–){ //goes through each speed from 255 to 0
//    analogWrite(motorPin, i);   //sets the new speed 
//    delay(delayTime);           // waits for delayTime milliseconds
UPDATED CODE AFTER PRESENTATION

 int potPin = 0;                           // Analog pin 0 connected to the potentiometer
int transistorPin = 9;                  // connected from digital pin 9 to the base of the transistor
int potValue = 0;                       // value returned from the potentiometer
void setup() {                          // set  the transistor pin as an output
  pinMode(transistorPin, OUTPUT);
}
void loop() {                           // read the potentiometer, convert it to between 0 – 255 for the value accepted by the digital pin.
  potValue = analogRead(potPin) / 4;    // potValue alters the supply from pin 9 which in turn controls the power running through the transistor
  analogWrite(9, potValue);
}