Introduction: UCL-IIoT Color Sorter

About: thor0982, rune1259 and casp6137

Introduction

In this instruction we will try to explain, how we are going to programming, and how we collect a color sort machine. It will be programmed in an Arduino Uno, through Arduino Software.

This project is an elective on our study. The meaning with it, is to learn about industry 4.0.

The thoughts behind this project is most of one from our team Casper thoughts, that he wants a machine that was able to sort out the colors from example a M&Ms bag. We have made this machine that from help from our sensor will sort the colors to some difference bowls.

Below here there is a list of the things we will come across during this guide.

STEP 1: Material list

STEP 2: Programing

STEP 3: Draws

STEP 4: Flowchart

STEP 5: Design of our machine

Step 6: Database

Step 7: Node Red

STEP 8: Video

Step 1: STEP 1: Material List

Material list

Arduino Nano

Arduino board

1 x USB cable

3D printer

laser cutter

Servomotor

Node Red

Various wires

Color sensor

9V supply

Breadboard Power Supply Module

Step 2: STEP 2: Programing

We use a

“switch case” to control the bottom servo, so when a case is called it write a position for the servo and it add 1 to the counter.

We use “if” fruition to detriment wort colour the sensor is seeing because it sees how much red, green and blue is reflected back.

Step 3: STEP 3: Draws

This picture shows how to connect you wires to your arduino,

on our model we have used a breadbord power supply to make enough power to our servo's and colour sensor.

but the most important is dont use the power supply from the arduino nano. connect it like the picture or like we do it

Step 4: STEP 4: Flowchart

We have made an overview, so people can see step by step what happens.

It is made in a free site on the internet called draw.io. When we tried to make it to a PDF it didn’t made it right, so we took some screenshots and called them by the name and page.

Step 5: STEP 5: Design of Our Machine and 3D Printing

We have found the design of our machine, on a website and big thanks to the website https://howtomechatronics.com/projects/arduino-col... .

we have used a lasercutter to cut our 3 mm thick wooden board and only one par of it is 6mm thick it is the top servo part, because we use M&M's and when it is 3mm thick the M&m's just glide out of it.

The laser cut we use adobe inventor

We have 3D printet a pibe and a holder to bottom servo to get the right angle.

Step 6: ​Step 6: Database

Step 6: Database

We have through Wampserver64 make a database.

In our database we have we chosen to store the different colors, and a Time to our variable.

Time, Red, Yellow, Green, Blue, Brown, Orange.

We will get information through node red, and node red will get the information from our Arduino.

Under our browser it will shows our colors and see if there is going to be stored a color.

Step 7: ​Step 7: Node Red

Step 7: Node Red

Node Red is a program you can install through your cmd on your computer.

Then in cmd you write node-red, and then it will start up.

Go to your browser and write http://127.0.0.1:1880. If you want dashboard its almost the same just write http://127.0.0.1:1880. then the page will show your dashboard.

In our node red we made a program where we going to connect our Arduino, and show the different colors, and have made a connection to our database.

When our database need to be reset we have a button to reset our database.

the code is:

[{"id":"994cb868.55db68","type":"tab","label":"Sorteringsmaksine","disabled":true,"info":""},{"id":"1370c730.4ce339","type":"function","z":"994cb868.55db68","name":"Node-RED MySQL","func":"var data = msg.payload.split(\",\");\nvar Red = data[0];\nvar Yellow = data[1];\nvar Green = data[2];\nvar Blue = data[3];\nvar Brown= data[4];\nvar Orange = data[5];\nvar out = \"INSERT INTO nodered.test (Time,Red,Yellow,Green,Blue,Brown,Orange) VALUES('\"+new Date().toISOString().slice(0, 19).replace('T', ' ')+\"','\"+Red+\"','\"+Yellow+\"','\"+Green+\"','\"+Blue+\"','\"+Brown+\"','\"+Orange+\"')\";\nmsg.topic = out;\nreturn msg;\n\n","outputs":1,"noerr":0,"x":233,"y":345.0000047683716,"wires":[["20130f47.c2bf8","1ceafc49.f3c8b4"]]},{"id":"93ffb56f.fa6dc8","type":"serial in","z":"994cb868.55db68","name":"","serial":"3f169279.b9201e","x":55,"y":160.8351821899414,"wires":[["1370c730.4ce339","c442248b.c568d8"]]},{"id":"20130f47.c2bf8","type":"debug","z":"994cb868.55db68","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":431.96460723876953,"y":430.5173387527466,"wires":[]},{"id":"c442248b.c568d8","type":"function","z":"994cb868.55db68","name":"Seperate","func":"var var1 = {topic: \"Red\", payload: msg.payload.split(\",\")[0]};\nvar var2 = {topic: \"Yellow\", payload: msg.payload.split(\",\")[1]};\nvar var3 = {topic: \"Green\", payload: msg.payload.split(\",\")[2]};\nvar var4 = {topic: \"Blue\", payload: msg.payload.split(\",\")[3]};\nvar var5 = {topic: \"Brown\", payload: msg.payload.split(\",\")[4]};\nvar var6 = {topic: \"Orange\", payload: msg.payload.split(\",\")[5]};\nreturn [var1, var2, var3, var4, var5, var6];","outputs":6,"noerr":0,"x":318.6243667602539,"y":160.39236545562744,"wires":[["858aa013.d37f5"],["43e409bc.322f98"],["132d0ea9.f596d1"],["8d487fa3.5b2ab"],["c95f0dd.901e9f"],["83e35329.16438"]]},{"id":"43e409bc.322f98","type":"ui_gauge","z":"994cb868.55db68","name":"Yellow","group":"d0f7cbee.dae548","order":2,"width":0,"height":0,"gtype":"gage","title":"Yellow","label":"","format":"{{value}}","min":0,"max":"1023","colors""#00b500","#e6e600","#ca3838"],"seg1":"333","seg2":"666","x":595.6242256164551,"y":68.39235019683838,"wires":[]},{"id":"858aa013.d37f5","type":"ui_gauge","z":"994cb868.55db68","name":"Red","group":"d0f7cbee.dae548","order":1,"width":0,"height":0,"gtype":"gage","title":"Red","label":"","format":"{{value}}","min":0,"max":"1023","colors""#00b500","#e6e600","#ca3838"],"seg1":"333","seg2":"666","x":595.6242275238037,"y":24.392335891723633,"wires":[]},{"id":"1ceafc49.f3c8b4","type":"mysql","z":"994cb868.55db68","mydb":"5c3df2e7.93773c","name":"","x":430.9680709838867,"y":271.96870613098145,"wires":[[]]},{"id":"132d0ea9.f596d1","type":"ui_gauge","z":"994cb868.55db68","name":"Green","group":"263a50c9.3773e","order":3,"width":0,"height":0,"gtype":"gage","title":"Green","label":"","format":"{{value}}","min":0,"max":"1023","colors""#00b500","#e6e600","#ca3838"],"seg1":"333","seg2":"666","x":597,"y":109,"wires":[]},{"id":"8d487fa3.5b2ab","type":"ui_gauge","z":"994cb868.55db68","name":"Blue","group":"263a50c9.3773e","order":4,"width":0,"height":0,"gtype":"gage","title":"Blue","label":"","format":"{{value}}","min":0,"max":"1023","colors""#00b500","#e6e600","#ca3838"],"seg1":"333","seg2":"666","x":600,"y":150,"wires":[]},{"id":"c95f0dd.901e9f","type":"ui_gauge","z":"994cb868.55db68","name":"Brown","group":"497776ce.542888","order":1,"width":0,"height":0,"gtype":"gage","title":"Brown","label":"","format":"{{value}}","min":0,"max":"1023","colors""#00b500","#e6e600","#ca3838"],"seg1":"333","seg2":"666","x":598,"y":187,"wires":[]},{"id":"83e35329.16438","type":"ui_gauge","z":"994cb868.55db68","name":"Orange","group":"497776ce.542888","order":2,"width":0,"height":0,"gtype":"gage","title":"Orange","label":"","format":"{{value}}","min":0,"max":"1023","colors""#00b500","#e6e600","#ca3838"],"seg1":"333","seg2":"666","x":607,"y":226,"wires":[]},{"id":"2c07ae63.7a3122","type":"function","z":"994cb868.55db68","name":"Delete list","func":"//name = msg.payload.name;\nmsg.topic = \"DELETE FROM test WHERE 3;\";\nconsole.log(msg.topic);\nreturn msg;","outputs":1,"noerr":0,"x":264.10000228881836,"y":386.0000057220459,"wires":[["1ceafc49.f3c8b4"]]},{"id":"eb9e9e1d.c402d","type":"ui_button","z":"994cb868.55db68","name":"","group":"4e829ead.73327","order":0,"width":0,"height":0,"passthru":false,"label":"Push to delete tabel","color":"","bgcolor":"","icon":"","payload":"true","payloadType":"bool","topic":"","x":138,"y":482.0000066757202,"wires":[["2c07ae63.7a3122"]]},{"id":"3f169279.b9201e","type":"serial-port","z":"","serialport":"COM4","serialbaud":"9600","databits":"8","parity":"none","stopbits":"1","newline":"\\n","bin":"false","out":"char","addchar":false,"responsetimeout":"10000"},{"id":"d0f7cbee.dae548","type":"ui_group","z":"","name":"Data","tab":"e3071416.09db28","order":2,"disp":true,"width":"6","collapse":false},{"id":"5c3df2e7.93773c","type":"MySQLdatabase","z":"","host":"127.0.0.1","port":"3306","db":"nodered","tz":""},{"id":"263a50c9.3773e","type":"ui_group","z":"","name":"DATA","tab":"e3071416.09db28","order":1,"disp":true,"width":"6","collapse":false},{"id":"497776ce.542888","type":"ui_group","z":"","name":"Data","tab":"e3071416.09db28","order":3,"disp":true,"width":"6","collapse":false},{"id":"4e829ead.73327","type":"ui_group","z":"","name":"Button","tab":"e3071416.09db28","order":5,"disp":true,"width":"6","collapse":false},{"id":"e3071416.09db28","type":"ui_tab","z":"","name":"Home","icon":"dashboard"}]