Introduction: Interactive LED Programmable Canvas
The Aim of this project was to go one step further with the custom canvas'. It cost a bit more but the potential is much greater for this design
Step 1: Theory
White LED Resistor Calcs
Vce = 0.3V @150mA
LED Voltage Drop = 3.2V @ 20mA
Vcc = 9V
9-0.3-3.2 = 5.5V -> 5.5/0.02 = 275R ~ 300R
Potential Divider to base of transistor
Ic = 20mA, BETA of 100
Ib = 20/100 = 0.2mA
Voltage divider on base needs 20 times 0.2mA = 20x0.2 = 4mA
Vin from Arduino = 3V3 and Vbe = 0.8 for 2N2222
3.3/0.004 = 825
Vout = Vin * R2/(R1+R2)
0.8 = 3.3 * R1/(1100)
R1 = 825*(0.8/3.3) = 200 (had a 200R resistor)
R2 = 825-200 = 625 (i didn't have a resister closer than 1K, still works)
Photodiode Calcs and Understanding
A photo diode works by changing the amount of current that it draws as the light increases and decreases.
The more light that it takes in the more current it will draw. As the current increases so does the voltage potential across it which is measured by the microcontroller through an ADC.
LED Voltage Drop = 3 - 3.4V (I used 3V)
Current Draw = 20mA
R = V/I where V = 9-3 and I = 0.02
R = 6/0.02 = 300ohm
Step 2: Parts List
I will be posting the progress i make on here, all of the mistakes, and the breakthroughs.
To start, here is a list of the items that i have purchased with links.
9V battery holder with switch (http://www.ebay.co.uk/itm/ALA6F22I-F-Plastic-9V-PP3-x1-Black-with-Cover-Switch-Leads-Battery-Holder-/171342692969?ssPageName=ADME:L:OU:GB:3160)
Adafruit Standalone Toggle Capacitive Touch Sensor Breakout (http://www.maplin.co.uk/p/adafruit-standalone-toggle-capacitive-touch-sensor-breakout-n52dq)
10x IR LEDs (http://www.ebay.co.uk/itm/110990614547)
The Canvas’ (http://www.artoncanvasdirect2you.co.uk/large-4-panel-multi-set-new-york-city-bridge-black-and-white-canvas-pictures-modern-home-decor-wall-4386-p.asp)
5x Photo Diode (http://www.ebay.co.uk/itm/PHOTODIODE-IR-FILTERED-Part-SFH203-FA-/271226770549?pt=UK_BOI_Electrical_Components_Supplies_ET&hash=item3f26601475)
Leonardo Pro Micro ATmega32U4 Arduino (http://www.ebay.co.uk/itm/231331757565)
10x 2N2222 Transistors (http://www.ebay.co.uk/itm/10pcs-2N2222-Transistors-General-Purpose-2N2222-NPN-TO-92-Package-/281419471748?ssPageName=ADME:L:OU:GB:3160)
1x White Bundle of Wire (http://www.ebay.co.uk/itm/10m-Bundle-7-0-2-Stranded-Wire-11-colours-Cable-Reel-Electronics-Arduino-Hookup-/151418997574?pt=UK_BOI_Electrical_Components_Supplies_ET&var=&hash=item2341468b46)
4 x Diffused White 3mm LED (25 pack) (http://www.adafruit.com/products/778#tutorials)
9V battery from any random store
100x 300ohm Resistors - (http://www.ebay.co.uk/itm/100x-Metal-Film-Resistor-1-4W-1-1st-Class-Postage-UK-Resistors-0-25W-/290739459734?ssPageName=ADME:L:OU:GB:3160)
Step 3: Testing
The first stage of testing was to see what kind of signal the sensor was outputting in this arrangement. The output from the sensors is a negative value because of the way the sensors are wired with their anode down to 0V. As an object gets closer to the sensor the value becomes less and less. To test this, code was developed to read the sensor and display it on the terminal screen on the computer (i used putty).
The next stage was to write some code to turn the LED (which at this point was a green LED because i didn't have the white ones yet) On/Off with the swipe of a hand. this can be seen in video 1.
The next test was to make the LED fade in and out with distance. this can be seen in video 2/
The next stage of testing was to test one white LED with a transistor and the battery. The code used in the video was the same as the fading code, only the electronics changed.
The final stage of testing of testing was to test multiple LEDs controlled by multiple sensors. I did this (as shown in the pictures above) with 4 transistors, 8 IR LEDs and 4 White LEDs. The outputs of the sensors go to A0-A4 of the Arduino, the IR LEDs are wired in pairs to digital pins on the Arduino and the base of the transistors are wired to 4 PWM pins on the Arduino. The video shows the full array of settings that i have programmed.
1 - Twinkle
2 - Fade in/Fade out
3 - On/Off
4 - Reaction Game
The video shows me using the Leonardo to control the LEDs. It must be noted that the code did change slightly from the Mega to the Leonardo because i used the timerOne library in the game code on the Mega and it worked fine. On the Leonardo, the timerOne function caused issues with the PWM pins so i had to resort to using a different method in the game code.
Step 4: Building
Select where the LEDs will be coming through the canvas and cut + shapes with a scalpel in those places. Remember the holes for the two IR LEDs and the Sensor. I placed them at the bottom of the canvas.
Get a piece of cardboard (i used a piece from a rigid envelope) and lay the canvas with the holes face down on it. Proceed to mark where the holes are on the cardboard by pushing a pencil through the holes and drawing on the cardboard.
Cut holes in the cardboard where the markings are.
Push LEDs through the holes in the cardboard and orientate them so all the anodes are pointing in the same direction.
Wire all the LEDs in parallel with 300ohm resistors between the anode and the 9V supply. Then wire all the cathode pins together. Wire the 1Mohm resistor to the anode of the Photodiode and wire the anodes of the IR LEDs together and the cathodes of the IR LEDs together. Also, solder the resistors in the correct configuration to the transistor base and connect its collector pin to the cathode of one of the LEDs.
Remve the components from the cardboard and push them through the holes in the canvas. Repeat for each canvas if you have multiple
If you have multiple canvas' (like me), fix the canvas' together by some means, i used thin pieces of wood nailed into the frame (shown in the picture).
Wire the canvas' together. The anodes of the white LEDs need to be connected together and the common ground needs to be created from the emitter of the transistor. This ground also needs to be connected to the Photodiode and the cathode of the IR LEDs.
Choose a position for the Microcontroller to sit in the canvas frame. Solder wires to the base resistor of the transistors, to the anode of the IR LEDs and to the anode pin of the Photodiode (not after the resistor, before),making sure that the wires can reach the relevant pins on the Arduino.
Connect the wires to the relative Arduino pins (tip: label the wires when you connect them) and connect the battery clip to the 9V line and ground. Make sure to connect a 9V wire and ground wire to the Arduino via the Vin or Vcc pin and GND pin respectively.
It is easier to do steps 8-10 when the components are in the canvas because the wires can be flimsy.
Test each set of LEDs individually by applying 9V to the resistor end and cathode of the LEDs. This will find any dud LEDs, wrong orientations or bad solder joints.
Step 5: Final Product
Here it is and here's the video of it working. The battery holder with switch broke so i had to resort to a simple clip where i have to remove the battery to turn it off.
There is two codes attached, game 1 and game 2. Game 1 has one game programmed in which is the reaction game. Game 2 has 2 game, the reaction game and a memory game.
Grand Prize in the
Make it Glow!