"The Color Sorter"

What does it do?

The color sorter main function is to sort the plastic bottle caps by color, the second function is to help recycling.

Who's done what beforehand?

Many people made some color sorter but only for candies. Some people within the Fab Academy and many on Youtube.
During the Machine Week the group (Grace, Jesus and myself) designed the machine

The 3D printed parts and used Arduino Uno as mainboard.


What did you design?

I changed some 3D printed parts, changed the design and material of the body and used the Xiao RP2040 for the electronics.
I added an OLED screen to see the count of the bottle caps.

Materials and components used.

Qty Description Price From
1 Crystal PLA 5$ (300g) Savin Shop in Santa Cruz (Bolivia)
1 Acrylic Board of 2mm 5$ Mundo Insumos Shop in Santa Cruz (Bolivia)
1 Acrylic Board of 3mm 5$ Mundo Insumos Shop in Santa Cruz (Bolivia)
1 Xiao RP2040 30$ Amazon Online Store
1 TCS34275 RGB Sensor 8$ Sawers Shop in Cochabamba (Bolivia)
2 Servo Motors 8$ Sawers Shop in Cochabamba (Bolivia)
1 Oled Screen I2C 6$ Sawers SDhop in Cochabamba (Bolivia)
1 PCB 3$ Sawers Shop in Cochabamba (Bolivia)
TOTAL 70$

What parts and systems were made?

All the 3D parts and body where made from scratch on Autodesk Fusion 360.

Here is the dxf file for the CNC.

3D Parts: Charger SensorGuide SensorSlider Slider SliderSupport

What processes were used?

2D Design for the CNC Cutting.
3D Design for the 3D Printed parts.
Additive process with the 3d printed parts.
Subtractive process with the laser cutting.
Electronic design and production with the embedded microcontroller.


      Here is the code:
         #include "Wire.h"
         #include "Adafruit_TCS34725.h"
         #include "Servo.h"

         Servo bottomServo;
         Servo topServo;

         int color=0;

         byte gammatable[256];

         Adafruit_TCS34725 tcs = Adafruit_TCS34725(TCS34725_INTEGRATIONTIME_50MS, TCS34725_GAIN_4X);
      
         void setup() {
      
         bottomServo.attach(7);
         topServo.attach(8);
         Serial.begin(9600);
      
         for (int i=0; i < 256; i++) {
         float x = i;
         x /= 255;
         x = pow(x, 2.5);
         x *= 255;

         gammatable[i] = x;
    
         }
         }

         void loop() {

         topServo.write(110);
         delay(800);
  
         for (int i=110;i>50;i--){
         topServo.write(i);
         delay(2);
         }  
         delay(800);
  
         color=readColor();
         delay(100);
   
         switch (color) {
    
         case 1:
         bottomServo.write(30);
         break;

         case 2:
         bottomServo.write(65);
         break;

         case 3:
         bottomServo.write(100);
         break;

         case 4:
         bottomServo.write(135);
         break;

         case 5:
         bottomServo.write(170);
         break;
    
         case 0:
         break;
    
         }
         delay(300);

         for(int i=50;i>0;i--){
         topServo.write(i);
         delay(2); 
         }
         delay(300);

         for(int i=0;i < 110;i++){
         topServo.write(i);
         delay(2);
         }
         color=0;
         }  

         int readColor(){
  
         float red, green, blue;
  
         tcs.setInterrupt(false);  // turn on LED

         delay(1000);  
 
         tcs.getRGB(&red, &green, &blue);
  
         tcs.setInterrupt(true);  // turn off LED

         Serial.print("R:\t"); Serial.print(int(red)); 
         Serial.print("\tG:\t"); Serial.print(int(green)); 
         Serial.print("\tB:\t"); Serial.print(int(blue));

         Serial.print("\n");

         Serial.print("Color:\t"); Serial.print(color) ;
         Serial.print("\n");  
         if(red>160 & green<60){
         color = 1; // Red
         }
         else if(blue>110){
         color = 2; // Blue
         }
         else if(green>105){
         color = 3; // Green
         }
         else if(red>140 & green>60){
         color = 4; // Orange
         }
         else{
         color = 5; // Others
         }
   
         return color; 
         }
        
       

What worked? What didn't?

The bending of cardboard of 3mm with laser worked very well, no so much with the acrilic of 3mm.
Even changing the cutting pattern.

The Xiao RP2040 never worked and I had to go back to Arduino Uno.

The new version of the machine will use the XIAO RP2040, a 360 servo motor, a smaller slider and 6 drawers made in PLA
The machine will be an all in one without external pieces.

How was it evaluated?

We made test with kids and persons that didn't belong to the FabLab.