-
1Step 1
Explanation circuit
The circuit has two main parts, the transimpedance amplifier and resistors settings RGB LED:
Transimpedance amplifier
This circuit serves to convert the intensity of the photodiode into a voltage and amplifying the signal of this, the resistance I was chosen to amplify the signal to acceptable values, the capacitor for filtering the signal, the integrated used is named before the pin negative integrated is 2, pin 3 is the positive pin, pin 1 is the output of OAMP, pin 4 is gnd that connects to gnd arduino and pin 6 is the pin that connects to 5v in arduino. Although the signal was acceptable we have changed the reference voltage Arduino manually, for this we have connected the 3.3 volt salidad arduino Aref, thus the reference voltage is 3.3V, making values showing in A0 be greater since the vref is lower than before (previously 5V).
The reference used was: https://outsidescience.wordpress.com/2012/10/10/diy-science-measuring-light-with-a-photodiode-i/
Resistance and LEDs
Each leg rgb has different resistance for calibrating the power emitted color so that the optical sensor receives the same power with each color when reflected by a white surface, it is important to note that the power of each LED color is different in a commercial led, and that the sensitivity of the colors is also different in the photodiode (it is more sensitive to green than red or blue). Part of red has a total resistance of 220 ohm formed by two resistors in series (100 + 120), the portion of blue has a total resistance of 250 ohms (100 + 150) and the portion of green has a resistance of 10 ohm . This setting is for the LED and photodiode used in this circuit, using another sensor or other RGB LED should be recalibrated. The method used was 3 colors reflect a pure white surface as possible and record the values obtained in the photodiode. Note that the led to be common anode is connected to the digital inputs of arduino (in this case 5,6 and 7) on the negative side, to make it work instead of a HIGH level we introduce a LOW level arduino.
-
2Step 2
Code
The code consists of two functions, one reads the colors and the other passes a 256 rgb format.
At the beginning of the code variables are created and told to arduino that uses an external reference, in this case the 3.3v which are connected to Aref.
The reading portion LED lights, wait 500ms (photodiode has time to notice color differences, it is usually very low, with this amount of time left over much but it's more to display the visual effect of changing a color to another) takes 10 readings and computes the average of these 10 readings, after it saves the value in an array, performs the same operation with the green and blue.
Part 256 format divides the values of each color array for the maximum value to reflect against a target of each color (in our case we obtain a value of 600) and multiplied by 256 to obtain the RGB value.
These two functions are called in the loop loop and after that in the Serial written to be read by processing.
The code expecting a change in the pin which is connected the button to start the reading sequence, the PIN pad is usually found in state high except when you press passing LOW, have an if checking this value and running the rest of the code when there is a LOW on pin D8 arduino.
Arduino will comment the code and processing so you can put it on page
The reference used to pass the values obtained in the photodiode 256 is values:
http://www.instructables.com/id/Using-an-RGB-LED-to-Detect-Colours/step4/Code-the-Arduino/
Especially the called function Checkcolour.
-
3Step 3
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.