PCOM – Week 08

Project 2 progress

This week, It took a long time for the vibration motors I bought to work well at first. The motor worked well when connected directly to the breadboard.
But it did not work when connected directly with the digital pin as below and with NPN transistor connected 1K ohm and 220 ohm (+ side) as well. Through an office hour with Danny, I found that resistance was a problem. So instead of 1k on the transistor side, I put 10k resistance to the NPN transistor base side and removed 220 ohm resistance to the ground. Finally, the motor worked well.

only works if it is connected to the breadboard directly.

10k ohm resistor to transistor base / no 220 ohm resistor -> works well.

SO, It tried my total 8 motors for 8 notes and it works well when 8 vibrating motors are applied to the arduino sketch as below.

const int motorPin1 = 2;
const int motorPin2 = 3; 
const int motorPin3 = 5;
const int motorPin4 = 6;
const int motorPin5 = 9;
const int motorPin6 = 10;
const int motorPin7 = 11;
const int motorPin8 = 12;


void setup()
{
  pinMode(motorPin1, OUTPUT);
  pinMode(motorPin2, OUTPUT);
  pinMode(motorPin3, OUTPUT);
  pinMode(motorPin4, OUTPUT);
  pinMode(motorPin5, OUTPUT);
  pinMode(motorPin6, OUTPUT);
  pinMode(motorPin7, OUTPUT);
  pinMode(motorPin8, OUTPUT);
}


void loop()
{
  digitalWrite(motorPin1, HIGH); //vibrate
  delay(1000);  // delay one second
  digitalWrite(motorPin1, LOW);  //stop vibrating
  delay(1000); //wait 50 seconds.
  // Serial.println(motorPin);
  
  digitalWrite(motorPin2, HIGH); //vibrate
  delay(1000);  // delay one second
  digitalWrite(motorPin2, LOW);  //stop vibrating
  delay(1000); //wait 50 seconds.

  digitalWrite(motorPin3, HIGH); //vibrate
  delay(1000);  // delay one second
  digitalWrite(motorPin3, LOW);  //stop vibrating
  delay(1000); //wait 50 seconds.

  digitalWrite(motorPin4, HIGH); //vibrate
  delay(1000);  // delay one second
  digitalWrite(motorPin4, LOW);  //stop vibrating
  delay(1000); //wait 50 seconds.

  digitalWrite(motorPin5, HIGH); //vibrate
  delay(1000);  // delay one second
  digitalWrite(motorPin5, LOW);  //stop vibrating
  delay(1000); //wait 50 seconds.
  
  digitalWrite(motorPin6, HIGH); //vibrate
  delay(1000);  // delay one second
  digitalWrite(motorPin6, LOW);  //stop vibrating
  delay(1000); //wait 50 seconds.

  digitalWrite(motorPin7, HIGH); //vibrate
  delay(1000);  // delay one second
  digitalWrite(motorPin7, LOW);  //stop vibrating
  delay(1000); //wait 50 seconds.

  digitalWrite(motorPin8, HIGH); //vibrate
  delay(1000);  // delay one second
  digitalWrite(motorPin8, LOW);  //stop vibrating
  delay(1000); //wait 50 seconds.

  
}

//https://techzeero.com/arduino-tutorials/vibration-motor-with-arduino/

try

P5 sketch: https://editor.p5js.org/kjbae0101/sketches/-cjN4KHxp

Arduino code:

https://create.arduino.cc/editor/katebae01/bbc51e44-e2a1-46cd-81d1-7bd032e97d5f

https://codeshare.io/Gk6rLY

================================================================

I am now founding out the code that connect the arduino through the following this p5 sketch and p5 Serial. I am working as there is a problem with the code.


My intention is that when I press the button on the p5 sketch, When each corresponding 8-notes is activated in the p5 sketch as follows, each of the 8 motors vibrate according to the notes.
but it seems not working now.
my current sketch only seems to receive the char when I click the bar that corresponds to the each note directly on the p5 sketch.

References