Arduino

Program One: Blink

4/23/18

Grab an Arduino computer and a USB cord. Connect the Arduino to the computer, and open the program for Arduino. Go to tools and select the Port that says "(Arduino Uno)"

Go to File, Examples, Basics, and click Blink. A new box should pop up with a program in it. Click the arrow, and the file will load onto the Arduino. The yellow light on the computer should blink on and off.

Program Two: Daughterboard

Grab a Daughterboard from the drawers by the Arduino. Plug it into the Arduino board, starting at GND and finishing at 9.

I open up the Blink program again, and copy and paste the program 5 times. Then, I go in and edit the numbers in parentheses. I keep one 13 the same, then change to the other numbers to 12, 11, 10, and 9. This makes all 5 LEDs blink, one after the other.

Program Three: Button

4/25/18

I grab a button and a daughterboard from the drawers. I connect the daughterboard in the same way as yesterday, and connect the button on the 2 pin and another GND pin.

Open up Arduino and change the Port like last time. Go to File, Examples, Digital, and click Button. Upload the file, and when you click the button, it should turn off the light. If this works, you can move on to changing the code.

Using elements from the Button code, I am going to create my own from scratch. The first step is establishing the Inputs and Outputs. I add the following, in the picture below. The "const int" and "int" values help the button to work on command. I copied this from the button code. In setup, I made the input "buttonPin," in other words, the real life button. The outputs are the 5 LEDs on the daughterboard, which is from the Daughterboard code. Once this is finished, I close it off with a }

I add the "digitalRead" so that when the button is pushed, it activates. The next step is an "if" statement. What this statement is saying is that when the button is NOT being pushed (HIGH), then all the lights will be off (LOW).

Finally, I use an "else" statement. This means that when the thing from the "if" is NOT happening, this will happen. This is essentially saying what will happen when the button IS pushed. I have made it so all FIVE daughterboard LEDs turn on when the button is pushed, rather than ONE light turning off when the button is pushed. I upload the code, and it works as planned!

Project Four: Analog Sensors

4/26/18

Grab a light sensor from the drawer and insert the wires based on their labeling on the sensor. The + wire goes to the 5V, the - goes to GND, and the OUT goes to A0. Once this is finished, copy the link from the Fab Lab Website and insert it into the Arduino window. This is what the code looks like without all the extra explanatory information.

Go to Tools and open the Serial Monitor. Make sure the baud is set to 9600. It should already be set to this. This window is where the values will be put once you upload the program.

Once you upload the program, a bunch of numerical values should appear in the serial monitor. Depending on where you face the sensor, the value will change. More light = higher number. I reach over 1000 when I shined a flashlight at the sensor. Once you have experimented with this a bit, you are finished!

Project Five: Analog + LED

Grab a daughterboard and keep the Light Sensor plugged in. This time we can use the light sensor to activate the LEDs on the daughterboard.

To make this code, I use elements from the sensor code and from some of my modified daughterboard codes. For the setup, I use the "Serial" part for the sensor, and make all the daughterboard LEDs Outputs.

For the loop, I set the Serial Monitor feature up again but using Serial.println(x). The x makes it so the LEDs will activate at a specific light level. I ser the minimum light level to 120. I use an if-else statement to say that when the light level is above 120, the LEDs will turn on, but when the light level is too low, they will shut off.

Now when there is more light, the LEDs turn on, and when there's not enough, they turn off.

Project Six: Do Something Cool!

4/30/18

For my "something cool," I'm going to make a pattern of lights that activate when it's exposed to light. I created my own code from scratch, using the things I learned.

The Setup was just saying all the LEDs were outputs

The start of loop makes the computer read the amount of light (A0 Reading). If this value is bigger than 120, the sequence starts. The first step is that the first LED will blink on and off twice.

I then continued this process with the other lights. The sequence goes first, third, second, then fourth (13, 11, 12, 10)

Then I made it so the first, third. and fifth lights blinked (13, 11, 9), then those turned off and the second and fourth turned on (12, 10). This repeats, then ALL 5 LEDs turn on. Then all the lights turn off, and the process begins again if there is enough light. If there is light for one second, the sequence completes no matter how much is there.

This was the result: