Tutorials and code for the four workshop project options.
The purpose of this project is to simulate a six sided die by programming six different LED lights
- Set up your hardware
- Connect ground wire to blue bus
- Connect pins 8-13 to the positive ends of the LEDs
- Use 270 ohm resistors to connect the negative ends to ground
- We must set our LED lights to specific pins in the Arduino. One LED will be set to pin 8, one LED is set to pin 9, and so on.
- Next we will set up the main body of die.
- Case #1: Just the first pin is on
- Case #2: Just the first two pins are on
- Case #3: Just the first three pins are on
- Case #4: The first four pins are on
- Case #5: The first five pins are on
- Case #6: All the pins are on
- The command for turning a light on is:
digitalWrite(pin1, HIGH)
,and the command for turning it off is:digitalWrite(pin2, LOW)
. - Press the reset button every time you wish to reroll the dice.
The purpose of this project is to program a multi-color LED, which changes colors as your hand approaches.
This multi-color light color changes when passing different voltages. Each of the three LEDs share a common cathode (negative) and there are three separate positives.
- Connect the RGB pins of the RGB LED (all pins but the longest one) to 270 ohm resistors.
- Connect the Digital IO pins (13,12,11) to the resistors.
- Ground the longest leg of the RGB LED.
- Set up the photo-resistor in a 5V voltage divider (look it up) with the photo-resistor at the lowest potential.
- Connect the A0 pin of the Arduino to the middle of the voltage divider.
- The
setup()
method will begin the serial communication between the Arduino, and the computer. In the void setup() method, assign the OUTPUT(s) and INPUT(s) using pinMode, for the red, green, blue and photo-resistor pins. - The
loop()
method is the part of the code that will repeat continuously. In the voidloop()
method, set the time delay in milliseconds. NOTICE that the timing always operates in milliseconds, and not seconds. - Now we will set the colors of the multi-color LED. The colors change based on the reduction in voltage. As the digital number representing the measured voltage changes, the colors change from red, to yellow, to green, to turquoise, to blue, and to purple.
- Lastly, the
analogWrite()
function writes the color values to the LED. Insert the inputs for the blue color.
Prerequisite: Dice
- Connect the two wires from the 3.5mm audio jack to two buses on the breadboard.
- Place three LEDS sequentially into the breadboard (with two dots spacing in between each LED).
- Connect the negative leads of the LEDs to the ground bus with 270 Ohm resistors. (Place a resistor below each LED on the bread board.) Be careful with polarity. (Bonus question: How does polarity matter?)
- Connect the positive terminals of the LEDs to pins 11-13 with wire.
- Connect the ground pin of the Arduino to the ground bus of the breadboard.
- Connect one of the two buses that the speaker is attached to to pin A0 of the arduino.
- Determine what voltage would make a good limit to turn music on. (Does this match the ceiling set in the code?)
- Play music through 8 ohm speakers by touching the wires together.
Hardware:
- Connect the ground pins of both arduinos together with a wire.
- Connect the A4 pins and the A5 pins, respectively, on both arduinos.
For the Master Writer:
- In the "Master Writer" file, in the setup, figure out the command to join the I2C bus (look at Arduino library).
- Figure out how to write "N" bytes to the I2C bus. Do this in the "Master Writer" loop.
- Figure out how to complete the transmission in the "Master Writer" loop.
- Set a reasonable delay at the end of the "Master Writer" loop.
For the Slave Receiver:
- Join the I2C bus as device 4 in the setup.
- Register the receive event in the setup.
- In the "Slave Receiver" loop, set a reasonable delay.
- In the receive event function, set the "while loop" parameters. Hint: you might have seen this before.
- In the while loop in the receive event function, read a byte from the I2C bus.