crazy paintbrush

Submitted by sebarness on Tue, 03/12/2013 - 15:55

For this assignment I attached a q-tip to the end of my motor and dipped it in water. The Q-tip spins around creating patterns on the paper. I also wanted the fsr to be under the paper and when the paintbrush is painting over the fsr the buzzer plays tones. 

Problems encountered: One of the wires on my motor came off and I cant fix it, also the q-tip is too light and the fsr has a hard time sensing it. I had tried using markers instead but the vibration of the motor was not strong enough to make a pattern. 

MATERIALS : 

-arduino

-dc motor

-potentiometer

-piezo buzzer

-wires

-breadboard

-q-tip

CODE:

 

 
int photoPin = A5;    // select the input pin for the potentiometer
int speakerPin = 7;
int soundState = 0;
int val = 0;
int potPin = 0;   // select the input pin for the potentiometer
int motorPin = 9; // select the pin for the Motor
 
void setup() {
  pinMode(speakerPin, OUTPUT); 
 
 
  
  Serial.begin(9600);
  Serial.println("ready");
}
 
void loop() {
  //turn everything off
  
  val = analogRead(potPin);    // read the value from the sensor, between 0 - 1024
  Serial.println(val);
  analogWrite(motorPin, val/4); // analogWrite can be between 0-255
  digitalWrite(speakerPin, LOW);
 
 
  
  soundState = analogRead(photoPin);
  Serial.println(soundState);
  
  // if the force sensor is pushed down enough, turn on the LEDs and make noise
  if (soundState > 200){
    int brightness = soundState/4;
    
   
 
    val = analogRead(photoPin);    // read value from the sensor
    val = val/2;                 // process the value a little
     
    for( int i=0; i<50; i++ ) {  // play it for 5 cycles
      digitalWrite(speakerPin, HIGH);
      delayMicroseconds(val);
      digitalWrite(speakerPin, LOW);
      delayMicroseconds(val);
    }
  }
}
photo (5).JPG
0
Your rating: None
Drupal theme by Kiwi Themes.