{"id":6171,"date":"2019-05-21T11:54:30","date_gmt":"2019-05-21T08:54:30","guid":{"rendered":"http:\/\/roboromania.ro\/?p=6171"},"modified":"2019-05-21T11:54:30","modified_gmt":"2019-05-21T08:54:30","slug":"folosirea-senzorului-detectie-culoare-tcs230-si-arduino-la-sortare","status":"publish","type":"post","link":"https:\/\/roboromania.ro\/?p=6171","title":{"rendered":"Folosirea Senzorului detec\u021bie culoare TCS230 \u0219i Arduino la sortare"},"content":{"rendered":"<h4><span style=\"color: #0000ff;\">Folosirea Senzorului detec\u021bie culoare TCS230 \u0219i Arduino la sortarea obiectelor colorate<\/span><\/h4>\n<p>Detec\u021bia culorii RGB cu senzorul <strong><span style=\"color: #0000ff;\"><a style=\"color: #0000ff;\" href=\"http:\/\/roboromania.ro\/produs\/modul-senzor-de-culoare-tcs230-589\/\" target=\"_blank\">TCS230<\/a><\/span><\/strong> \u0219i sortarea obiectelor colorate cu un Arduino <strong><span style=\"color: #0000ff;\"><a style=\"color: #0000ff;\" href=\"http:\/\/roboromania.ro\/produs\/nano-placa-de-dezvoltare-compatibila-arduino\/\" target=\"_blank\">NANO<\/a><\/span><\/strong> si doua <strong><span style=\"color: #0000ff;\"><a style=\"color: #0000ff;\" href=\"http:\/\/roboromania.ro\/produs\/servo-motor-9g-micro-compatibil-arduino\/\" target=\"_blank\">servomotoare<\/a><\/span><\/strong><\/p>\n<p><a href=\"http:\/\/roboromania.ro\/wp-content\/uploads\/2019\/05\/Arduino-Color-Sorting-Machine.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-6172\" src=\"http:\/\/roboromania.ro\/wp-content\/uploads\/2019\/05\/Arduino-Color-Sorting-Machine-300x178.jpg\" alt=\"arduino-color-sorting-machine\" width=\"300\" height=\"178\" srcset=\"https:\/\/roboromania.ro\/wp-content\/uploads\/2019\/05\/Arduino-Color-Sorting-Machine-300x178.jpg 300w, https:\/\/roboromania.ro\/wp-content\/uploads\/2019\/05\/Arduino-Color-Sorting-Machine.jpg 960w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p><a href=\"http:\/\/roboromania.ro\/wp-content\/uploads\/2019\/05\/Color-Sorting-Machine-Arduino-Project-Solidworks-Model.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-6173\" src=\"http:\/\/roboromania.ro\/wp-content\/uploads\/2019\/05\/Color-Sorting-Machine-Arduino-Project-Solidworks-Model-300x280.jpg\" alt=\"color-sorting-machine-arduino-project-solidworks-model\" width=\"300\" height=\"280\" srcset=\"https:\/\/roboromania.ro\/wp-content\/uploads\/2019\/05\/Color-Sorting-Machine-Arduino-Project-Solidworks-Model-300x280.jpg 300w, https:\/\/roboromania.ro\/wp-content\/uploads\/2019\/05\/Color-Sorting-Machine-Arduino-Project-Solidworks-Model.jpg 346w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>Uite \u0219i un cod pentru inspira\u021bie :<\/p>\n<p>\/\/&#8211;&#8211;&#8211;&#8211;&#8211;&#8211;&#8211;&#8211;&#8211;<\/p>\n<p>#include &lt;Servo.h&gt;<br \/>\n#define S0 2<br \/>\n#define S1 3<br \/>\n#define S2 4<br \/>\n#define S3 5<br \/>\n#define sensorOut 6<br \/>\nServo topServo;<br \/>\nServo bottomServo;<br \/>\nint frequency = 0;<br \/>\nint color=0;<br \/>\nvoid setup() {<br \/>\npinMode(S0, OUTPUT);<br \/>\npinMode(S1, OUTPUT);<br \/>\npinMode(S2, OUTPUT);<br \/>\npinMode(S3, OUTPUT);<br \/>\npinMode(sensorOut, INPUT);<br \/>\n\/\/ Setting frequency-scaling to 20%<br \/>\ndigitalWrite(S0, HIGH);<br \/>\ndigitalWrite(S1, LOW);<br \/>\ntopServo.attach(7);<br \/>\nbottomServo.attach(8);<br \/>\nSerial.begin(9600);<br \/>\n}<br \/>\nvoid loop() {<br \/>\ntopServo.write(115);<br \/>\ndelay(500);<\/p>\n<p>for(int i = 115; i &gt; 65; i&#8211;) {<br \/>\ntopServo.write(i);<br \/>\ndelay(2);<br \/>\n}<br \/>\ndelay(500);<\/p>\n<p>color = readColor();<br \/>\ndelay(10);<br \/>\nswitch (color) {<br \/>\ncase 1:<br \/>\nbottomServo.write(50);<br \/>\nbreak;<br \/>\ncase 2:<br \/>\nbottomServo.write(75);<br \/>\nbreak;<br \/>\ncase 3:<br \/>\nbottomServo.write(100);<br \/>\nbreak;<br \/>\ncase 4:<br \/>\nbottomServo.write(125);<br \/>\nbreak;<br \/>\ncase 5:<br \/>\nbottomServo.write(150);<br \/>\nbreak;<br \/>\ncase 6:<br \/>\nbottomServo.write(175);<br \/>\nbreak;<\/p>\n<p>case 0:<br \/>\nbreak;<br \/>\n}<br \/>\ndelay(300);<\/p>\n<p>for(int i = 65; i &gt; 29; i&#8211;) {<br \/>\ntopServo.write(i);<br \/>\ndelay(2);<br \/>\n}<br \/>\ndelay(200);<\/p>\n<p>for(int i = 29; i &lt; 115; i++) {<br \/>\ntopServo.write(i);<br \/>\ndelay(2);<br \/>\n}<br \/>\ncolor=0;<br \/>\n}<br \/>\n\/\/ Custom Function &#8211; readColor()<br \/>\nint readColor() {<br \/>\n\/\/ Setting red filtered photodiodes to be read<br \/>\ndigitalWrite(S2, LOW);<br \/>\ndigitalWrite(S3, LOW);<br \/>\n\/\/ Reading the output frequency<br \/>\nfrequency = pulseIn(sensorOut, LOW);<br \/>\nint R = frequency;<br \/>\n\/\/ Printing the value on the serial monitor<br \/>\nSerial.print(&#8222;R= &#8222;);\/\/printing name<br \/>\nSerial.print(frequency);\/\/printing RED color frequency<br \/>\nSerial.print(&#8221; &#8222;);<br \/>\ndelay(50);<br \/>\n\/\/ Setting Green filtered photodiodes to be read<br \/>\ndigitalWrite(S2, HIGH);<br \/>\ndigitalWrite(S3, HIGH);<br \/>\n\/\/ Reading the output frequency<br \/>\nfrequency = pulseIn(sensorOut, LOW);<br \/>\nint G = frequency;<br \/>\n\/\/ Printing the value on the serial monitor<br \/>\nSerial.print(&#8222;G= &#8222;);\/\/printing name<br \/>\nSerial.print(frequency);\/\/printing RED color frequency<br \/>\nSerial.print(&#8221; &#8222;);<br \/>\ndelay(50);<br \/>\n\/\/ Setting Blue filtered photodiodes to be read<br \/>\ndigitalWrite(S2, LOW);<br \/>\ndigitalWrite(S3, HIGH);<br \/>\n\/\/ Reading the output frequency<br \/>\nfrequency = pulseIn(sensorOut, LOW);<br \/>\nint B = frequency;<br \/>\n\/\/ Printing the value on the serial monitor<br \/>\nSerial.print(&#8222;B= &#8222;);\/\/printing name<br \/>\nSerial.print(frequency);\/\/printing RED color frequency<br \/>\nSerial.println(&#8221; &#8222;);<br \/>\ndelay(50);<br \/>\nif(R&lt;45 &amp; R&gt;32 &amp; G&lt;65 &amp; G&gt;55){<br \/>\ncolor = 1; \/\/ Red<br \/>\n}<br \/>\nif(G&lt;55 &amp; G&gt;43 &amp; B&lt;47 &amp;B&gt;35){<br \/>\ncolor = 2; \/\/ Orange<br \/>\n}<br \/>\nif(R&lt;53 &amp; R&gt;40 &amp; G&lt;53 &amp; G&gt;40){<br \/>\ncolor = 3; \/\/ Green<br \/>\n}<br \/>\nif(R&lt;38 &amp; R&gt;24 &amp; G&lt;44 &amp; G&gt;30){<br \/>\ncolor = 4; \/\/ Yellow<br \/>\n}<br \/>\nif(R&lt;56 &amp; R&gt;46 &amp; G&lt;65 &amp; G&gt;55){<br \/>\ncolor = 5; \/\/ Brown<br \/>\n}<br \/>\nif (G&lt;58 &amp; G&gt;45 &amp; B&lt;40 &amp;B&gt;26){<br \/>\ncolor = 6; \/\/ Blue<br \/>\n}<br \/>\nreturn color;<br \/>\n}<\/p>\n<p>\/\/&#8211;&#8211;&#8211;&#8211;&#8211;&#8211;&#8211;&#8211;&#8211;&#8211;&#8211;&#8211;&#8211;&#8211;<\/p>\n<p class=\"entry-title cb-entry-title cb-single-title\">Mai multe detalii : <a href=\"https:\/\/howtomechatronics.com\/projects\/arduino-color-sorter-project\/\" target=\"_blank\">Arduino Color Sorter Project<\/a><\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Folosirea Senzorului detec\u021bie culoare TCS230 \u0219i Arduino la sortarea obiectelor colorate Detec\u021bia culorii RGB cu senzorul TCS230 \u0219i sortarea obiectelor colorate cu un Arduino NANO si doua servomotoare Uite \u0219i un cod pentru inspira\u021bie : \/\/&#8211;&#8211;&#8211;&#8211;&#8211;&#8211;&#8211;&#8211;&#8211; #include &lt;Servo.h&gt; #define S0 2 #define S1 3 #define S2 4 #define S3 5 #define sensorOut 6 Servo topServo; [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[176],"tags":[],"class_list":["post-6171","post","type-post","status-publish","format-standard","hentry","category-tutoriale-arduino"],"_links":{"self":[{"href":"https:\/\/roboromania.ro\/index.php?rest_route=\/wp\/v2\/posts\/6171","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/roboromania.ro\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/roboromania.ro\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/roboromania.ro\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/roboromania.ro\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=6171"}],"version-history":[{"count":1,"href":"https:\/\/roboromania.ro\/index.php?rest_route=\/wp\/v2\/posts\/6171\/revisions"}],"predecessor-version":[{"id":6174,"href":"https:\/\/roboromania.ro\/index.php?rest_route=\/wp\/v2\/posts\/6171\/revisions\/6174"}],"wp:attachment":[{"href":"https:\/\/roboromania.ro\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=6171"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/roboromania.ro\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=6171"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/roboromania.ro\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=6171"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}