color sensor
thingiverse
The resistances for the LEDs are 150 ohms and 10 kilohms for the detector. The code: /* * Color sensor using blue, green, and red LEDs and photodiode * by Desperado */ #define blue A0 #define green A1 #define red A2 int color_blue; int color_green; int color_red; int max_value = 0; int min_value = 0; void setup() { pinMode(blue, INPUT); pinMode(green, INPUT); pinMode(red, INPUT); Serial.begin(9600); } void loop() { color_blue = analogRead(blue); color_green = analogRead(green); color_red = analogRead(red); Serial.print("blue: "); Serial.println(color_blue); Serial.print("red: "); Serial.println(color_red); Serial.print("green: "); Serial.println(color_green); Serial.println(); // Detection of white if (color_blue <= 300 && color_red <= 80 && color_green >= 55) { Serial.println("WHITE"); } // detection of blue else if (color_blue <= 350 && color_red >= 135 && color_green <= 100) { Serial.println("BLUE"); } // detection of green else if (color_blue >= 380 && color_red <= 140 && color_green >= 90) { Serial.println("GREEN"); } // detection of red else if (color_blue >= 380 && color_red <= 80 && color_green <= 85) { Serial.println("RED"); } // detection of black else if (color_blue >= 460 && color_red >= 170 && color_green >= 130) { Serial.println("BLACK"); } // unknown color else { Serial.println("UNKNOWN COLOR"); } Serial.println(); delay(1000); }
With this file you will be able to print color sensor with your 3D printer. Click on the button and save the file on your computer to work, edit or customize your design. You can also find more 3D designs for printers on color sensor.