Project Desription
When a sound is made, this project rotates a motor with an accelerometer attached. When the accelerometer is rotated, a LED light blinks.
Detail Photos
Process Photos
One of the earliest decisions we had to make was what LED to use to blink light. We liked the idea of using the LED with the bars in order to show different levels of input, but realized that it would be more difficult for the group whose input was light to detect the changes.
In our initial iteration of this project, we stuck to simpler parts and worked with one input at a time. We used a smaller servo motor and taped a popsicle stick to the end, with the accelerometer taped on top of that to detect motion. We also used a basic 5V LED light. Once we got these smaller parts to work with our software, we changed some of the parts to refine the project. For example, we used a bigger servo motor to both create a greater range of motion and to reduce the noise interference with the sound input (the small servo motors are quite noisy!).
In our later iterations of this project, we added better and more secure wiring (not just using long streams of female-male parts) and mounted the parts to cardboard to make it more secure and standardized (which was important for detecting motion).
Discussion
Our initial approach was to start with the parts we knew and had learned about in the class and make sure they worked with the software we wrote before upgrading the parts to make the project more refined. We thought this approach was really helpful for us, and helped us to really perfect our software before having to fiddle with the hardware. For future projects, we think that this iterative, simplified approach will be a helpful guideline to follow.
One of the hardest parts of this project was defining the threshold for sound and motion. It was really difficult to test sound due to the noise of the rooms we were in, the noise coming from our parts, and due to the overall noisy nature of detecting analog input. We were able to find a good threshold only through multiple series of testing and iterating, in which we watched the serial plotter religiously and tried to identify peaks in the data points. We followed this same process for detecting motion with the accelerometer; we watched and used the data we saw on the serial plotter to inform our decisions for thresholds. We found that the data gained from the accelerometer was not at all what we expected as the largest peaks were shown through the z-axis. Rather than relying on our intuition, it was really important for us to rely on the empirical data we saw through testing, and to use that to write our code.
One of the easier parts of this project was implementing the light output, as we were familiar with the LED part and had used it for multiple previous projects. We considered using a neo-pixel diffused LED, which could take inputs and change color based on those inputs, but we found the library difficult to use and ultimately decided that, since the output was sound and not color, using the simple LED would suffice.
Because we stuck to the parts and signals that we were relatively familiar with, we may have limited ourselves in the project we were able to produce. While our project ultimately fulfilled the task handed to us, there may have been ways that we could have made our project “cooler” or more interesting had we gone more out of our comfort zones and experimented with new parts and signals. In the future projects for this class, we both hope to think more creatively and try new and wildly different things to create really interesting projects.
Schematic
Code
// Double Transistor from Sound - Motion - Light // // Every half of a second, the program reads the input from a mic // if the mic input is greater than a certain threshold (entered here as 725) // it moves the servo motor // within the loop the code is always checked the input from the accelerometer // if the z-axis moves above a threshold, we turn on a LED light // //ARDUINO INPUTS // A2 | MIC INPUT // A3 | ACCELEROMETER INPUT // //ARDUINO OUTPUTS // A1 | SERVO MOTOR // 5 | LED LIGHT #include <Servo.h> const int MIC_IN = A2; const int SERVO_OUT = A1; const int LED_IN = 5; // For this device, we only read the Z PIN const int ZPIN = A5; int servoSwitch = 0; Servo servo; void setup() { pinMode(MIC_IN, INPUT); pinMode(LED_IN, OUTPUT); pinMode(SERVO_OUT, OUTPUT); pinMode(XPIN, INPUT); pinMode(YPIN, INPUT); pinMode(ZPIN, INPUT); servo.attach(SERVO_OUT); } void loop() { //check if z-axis of the accelerometer is above threshold if (analogRead(ZPIN) > 300) { digitalWrite(LED_IN, HIGH); } else { digitalWrite(LED_IN, LOW); } //checking mic input for half a second every second if (millis() % 1000 < 500) { if (analogRead(MIC_IN) > 725) { servoMove(); } } } //moves the servo back and forth once void servoMove() { if (servoSwitch) { servo.write(5); servoSwitch = 0; } else { servo.write(85); servoSwitch = 1; } delay(100); }
Comments are closed.