Lab 2

The objective of this second lab was to understand how circuitry could be affected by manipulations of code. Below is a picture of the initial circuit that I created.





Before observing each altered code, I used the “Verify” function of Arduino to make sure that each of them was valid. I then began the experiment portion documented my results for each individual code.




I altered this particular code by first including an else{} function between digitalWrite (led, 1) and digitalWrite (led, 0). I then swapped the 1 and 0 from their respective digitalWrite portion. Finally, I removed the delays from the code. Once the code was verified and uploaded, the Arduino instantly triggered the LED to stay permanently illuminated. However, when I pressed the button, the LED turned off for as long as my finger continued to push the button.


In this particular code, 1 and 0 are respectively representative of HIGH and LOW, or light or no light. The initial code without any alteration would cause the LED light of the circuit to become illuminated when the button was pressed. However, the added else{} function caused the program to override the if{} statement and keep the LED illuminated when the button was not being pressed. Similarly, it caused the LED to turn off as long as the button remained pressed. Removing the delays from the code also triggered an immediate response from the button, whereas in the initial code, there would have been a 1000ms delay between the pressing/release of the button and the appearance/disappearance of light from the LEDs.




I repasted the original code to the Arduino, including the delay times that I had previously removed. I then altered the delay time to 500ms so that I could observe the blinking of the LEDs much more quickly. Next, I moved digitalWrite(led, 1) before digitalWrite (led, 0) to trigger the lights to blink when the switch was off. I then changed the greater-than-symbol in if(analogRead(1) > 512) to if(analogRead(1) < 512), which caused the blinking to stop once the button was pressed.




In the turnPot = analogRead function, I changed the 250 to 0, making the delay time 0-2048ms.




In the same function, I changed 0 to 128, creating a new maximum delay time of 128 ms.




I toyed with the potentiometer in order to observe the different rates of clicks. I observed an audible click that sounded in conjunction with each flash of the LED. Depending on the direction, turning the potentiometer either increased or decreased the rate at which both the sound and light were emitted.




I first switched the wire connecting pin 13 and the LED so that the light was connected to pin 11, as the DvsA code called for that particular pin to be used. I observed that the light and sound reacted differently to the turning of the potentiometer while the button was pushed. The LEDs grew more intense as the dial was turned farther to the right. The sound, on the other hand, was completely mute if the potentiometer was turned completely to either the right or left. The sharpest sound was emitted when the potentiometer’s dial was turned directly to the center. My conclusion was that the levels of emitted sound varied based on the proximity of the dial’s position to its center.




The dubStop sketch initially elicits a rapid flashing of the LED light that gradually becomes slower. The potentiometer controlled the frequency at which the flashing lights loop. A synth sound corresponded with the lights, initially hard and quick in tone and rate before similarly decreasing in intensity over time. I added an extra zero to each number in the array in order to test out different tempi at which the sound and light could be emitted. This resulted in a quicker decrease in rate over time for both the clicks and flashes.


dubStop comments (in Bold)

// Pin 13 has an LED connected on most Arduino boards.
// give it a name:
int led = 13;
int turnPot; // declare a variable to be used later
int dubspeed = 25;

// this is an array
int speedRay[] = {
100, 130, 160, 220, 270, 330, 370, 400, 450, 500, 550, 600};

// the setup routine runs once when you press reset:
void setup() {

pinMode(led, OUTPUT);

// the loop routine runs over and over again forever:
void loop () {

for(int i = 0; i< dubspeed; i++){ // “i” decides the initial rate of blinking

if(analogRead(1) > 512){ //if A1 button pressed, LED flashes

dubspeed = speedRay[int((analogRead(0) * 0.01) + 1)] ; //represents decrease in rate

turnPot = i; //assigning turnPot to “i”

digitalWrite(led, HIGH); //turns LED on
delay(turnPot); //position of potentiometer regulates the delay
digitalWrite(led, LOW); //turns LED off
}//end if analogRead(1)

i = 0;
//end else

}//end for loop

}//end loop

Final Project

Inspired by my little sister, I’ve been considering creating a sound-light coordinated music box. My ideal final product, at the current moment, would be a combination and expansion upon two projects that I found interesting.


Rainbow LED Fader


Mp3 Music Box


I would like the box to play an actual mp3 recording as opposed to an 8 bit interpretation. In addition, I’d like to actually record an original song (fairly brief) that could be used as the mp3 that I’d like to be played. The idea is that the final product would be a nightlight-music box for small children when they go to bed.

About these ads

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s