For this week's assignment, I wanted to create a device that would assist musicians in keeping track of their beat number during rehearsals. This includes all sorts of musicians, including those that use their voice. As a member of the undergraduate chorus, I cannot verbally count beats (since I'm actively singing already). A stepper motor could be used to precisely time the rotations of the machine to match the tempo.
The core of this machine is the Nema 17 Bipolar 45Ncm (64oz.in) 2A 42x42x40mm stepper motor. The motor operates at a rated current of 2A with step angles of 1.8 degrees. To program the stepper motor, I used an A4988 microstepping driver and followed this tutorial to get started.I used the gemometric cardboard triangles that I laser cut in Week 2 to construct the numbering display of my rotational counting machine. I used a hand drill to make a hole in the central cardboard piece to set upon the stepper, and built the rest of the counter out from that with numbers ranging from 1-6.
The Arduino code below was uploaded to an Arduino UNO and specifies the rotational speed depending on the tempo. A sample tempo of 120 beats per minute is shown.
// defines pins numbers
const int stepPin = 12;
const int dirPin = 13;
// defines Tempo
#define TEMPO 120
void setup() {
// Sets the two pins as Outputs
pinMode(stepPin,OUTPUT);
pinMode(dirPin,OUTPUT);
}
void loop() {
digitalWrite(dirPin,HIGH); // Enables the motor to move in a particular direction
// Makes TEMPO/200 pulses for making one full cycle rotation
for(int x = 0; x < TEMPO/200; x++) {
digitalWrite(stepPin,HIGH);
delayMicroseconds(500);
digitalWrite(stepPin,LOW);
delayMicroseconds(500);
}
delay(100); // 0.1 second delay
}