Final Project: Construction and Coding

After we completed our design and figured out materials last week, we started the construction of our device.  We had to wait for our LEDs and transistors to arrive, so in the meantime we wrote our code using three single LEDs and tested them with our sound sensor and Servo motors.

This was the first code we wrote that made the LEDs turn on and off correctly according to the sound level.  We used three red LEDs and labeled them Red, Yellow, and Green.  To test the sound level, we used a tone generator and also tried using our own voices.




Next, we figured out the Servo motors.  We can set the Servos to a position from 0 to 180.  The following code, we have the commands for the motors in each if-else statement.  The "Too Loud" message shows when the red section is on, and the "Good Job" message shows when the green section is on.  For the yellow section, there is no message.  Below is our code with the Servo motors.





Once we had our LED strips arrived, we began soldering each row together.  The red section has 5 rows of 4 strips, the yellow section has 5 rows of 3 strips, and the green section has 5 rows of 2 strips.  The soldering was one of the most time-consuming parts of our project.

We then connected the LED to the Arduino to make sure they worked.  Some of the soldering wasn't perfect, so the yellow section had some trouble with the colors.  We have our 4 LED strips, 2 Servo motors, and the sound sensor connected to the Arduino.  It is powered by a 9V battery pack that is connected to the protoboard through the Vin pin.

We then incorporated the LED Strips into the code.  The LED strips use code that is a little bit different from the single LEDs.  Each strip has a red, green, and blue wire.  For the red section, we use only the red.  For the yellow section, we use red and green to create yellow.  And for the green section, we just use the green wire.  So in our code and on our Arduino, we are using four pins in total for the LED strips.  The main difference is that the yellow uses two pins, and we turn both of them on to create yellow.



Once the code, LEDs, and Servos worked, we used the laser cutter to print out the back piece, the two messages, and the 3 smiley faces.  The LED strips have adhesive on the back, so we attached all of the LEDs to the Delrin back piece.




The next step for us was attaching everything on the back of the Delrin:  the two servo motors and actuators, the two protoboards, the battery pack, and the Arduino.   For the two Servo motors with messages, we used Legos to create a track for the actuator and we built small platforms for the motors with gears.  We used hot glue to secure the Legos and motors.  The two protoboards have adhesive on the back, so we put them on either side of the Arduino.  The Arduino is held by building Legos around it, so that it is easily removable.

Finally, we wanted to make the transition between each section less jerky and so we averaged the readings from the sound sensor over time.  We tried two different approaches to this problem, and found that the following code worked the best.




No comments:

Post a Comment