Smart Conveyor
2024-08-26 | By M5Stack
License: General Public License Bluetooth / BLE Wifi Arduino M5Stack ESP32
* Thanks for the source code and project information provided by @farhan, 郭亮, Kesavaram Jignesh, Junwei123
Process
We aim to create a smart conveyor that utilizes sensors to detect when an item has been removed from the conveyor belt, when the item has been removed from the conveyor belt, it would start moving until the next item is detected which would make the conveyor stop. This is to ensure that when workers pick up an item to inspect its quality they would not need to manually wait for the item to come to them and stop it through a button for example. By doing so the workers would have more time to inspect the quality of the products which helps the factory to produce high-quality products and decreases defects being sent out from the factory.
Code
{"components":[{"id":"____screen","createTime":1674097348169,"name":"screen","x":0,"y":0,"width":320,"height":240,"backgroundColor":"#222222","backgroundImage":"","type":"screen"},{"id":"____buttonA","createTime":1674097348169,"name":"ButtonA","buttonIndex":0,"x":35,"y":216,"width":64,"height":24,"text":"ButtonA","visibility":false,"type":"button"},{"id":"____buttonB","createTime":1674097348169,"name":"ButtonB","buttonIndex":1,"x":125,"y":216,"width":64,"height":24,"text":"ButtonB","visibility":false,"type":"button"},{"id":"____buttonC","createTime":1674097348169,"name":"ButtonC","buttonIndex":2,"x":215,"y":216,"width":64,"height":24,"text":"ButtonC","visibility":false,"type":"button"},{"id":"@Jc!w#yhQqi0ePp*","createTime":1674097941260,"isCoreTwo":false,"isPaper":false,"name":"label0","x":19,"y":112,"color":"#000000","text":" _","font":"lcd.FONT_Default","rotation":0,"type":"label","layer":4}],"type":"fire","versions":"Beta","units":[{"id":"RFb#zvzWUCwxpn-F","createTime":1675181578994,"stickNone":"stick","type":"tof","name":"tof_0","port":"A","default":["A","E","PAHUB","Custom"],"pb_port":[0,1,2,3,4,5],"new_pb_port":"0","user_port":["21","22"],"icon":"tof.png","new_port":"A","new_default":["A","E","PAHUB","Custom"]},{"id":"dXNuboeyBQ51oAi!","createTime":1675181578994,"type":"servo","name":"servo_0","port":"B","default":["A","B","E","Custom"],"user_port":["21","22"],"icon":"servo.png","new_port":"B","new_default":["A","B","E","Custom"]}],"hats":[],"blockly":"<variables><variable id=\"Xt.Yi4F7A@MV8!qHQso*\">distance</variable></variables><block type=\"servo_init\" id=\"43icO}APcxy,^JgyKp7W\" disabled=\"true\" x=\"-310\" y=\"-210\"><field name=\"VARNAME\">servo0</field><value name=\"PIN\"><shadow type=\"math_number\" id=\"%3WMrqG4bn^r+td+(gF+\" disabled=\"true\"><field name=\"NUM\">22</field></shadow></value><value name=\"FREQ\"><shadow type=\"math_number\" id=\"Pc$)_=R@Q~S[1aq`Z82,\" disabled=\"true\"><field name=\"NUM\">50</field></shadow></value><value name=\"MIN_US\"><shadow type=\"math_number\" id=\"_}wI(TM_gBNJ|BKEdg0J\" disabled=\"true\"><field name=\"NUM\">500</field></shadow></value><value name=\"MAX_US\"><shadow type=\"math_number\" id=\"|(@z,(fOYf/fqUtr.[t%\" disabled=\"true\"><field name=\"NUM\">2500</field></shadow></value><value name=\"ANGLE\"><shadow type=\"math_number\" id=\"JwIWxr}CxzQ{RGOm[{@%\" disabled=\"true\"><field name=\"NUM\">180</field></shadow></value></block><block type=\"basic_on_setup\" id=\"setup_block\" deletable=\"false\" x=\"-270\" y=\"-50\"><next><block type=\"basic_on_loop\" id=\"^MXf6c*B3OdmZ)k{M4Xr\"><statement name=\"LOOP\"><block type=\"variables_set\" id=\"qLu}7zZACsNyOPe:_y8E\"><field name=\"VAR\" id=\"Xt.Yi4F7A@MV8!qHQso*\">distance</field><value name=\"VALUE\"><block type=\"convent_int\" id=\"MY6jGXv-T3uR`lONmiiE\"><value name=\"VALUE\"><block type=\"math_arithmetic\" id=\"^aTk6$6#dw^}tL+5u(7:\"><field name=\"OP\">DIVIDE</field><value name=\"A\"><block type=\"unit_tof_state\" id=\"F|^!R6Y3#C;5b}mZ]3H)\"><field name=\"TOF\">tof_0</field></block></value><value name=\"B\"><block type=\"math_number\" id=\"H6ap)C*P!7|/G,|yr/-$\"><field name=\"NUM\">10</field></block></value></block></value></block></value><next><block type=\"label_set_text\" id=\"Xn@)jZz(IlaG8X=a%wJV\"><field name=\"COMPONENT\">label0</field><value name=\"TEXT\"><shadow type=\"text\" id=\"M5KWko}yfUstgRT*3uJ_\"><field name=\"TEXT\">Hello M5</field></shadow><block type=\"variables_get\" id=\"Rz!FgFQmC/UrSn!G3uy#\"><field name=\"VAR\" id=\"Xt.Yi4F7A@MV8!qHQso*\">distance</field></block></value><next><block type=\"controls_if\" id=\"isg=Px7~:01r)x60a/G|\"><mutation else=\"1\"></mutation><value name=\"IF0\"><block type=\"logic_compare\" id=\"^nSo:ODt8lbPt(q0W=/.\"><field name=\"OP\">LTE</field><value name=\"A\"><block type=\"variables_get\" id=\"s_(H:%Sk?RccNWAHTK_]\"><field name=\"VAR\" id=\"Xt.Yi4F7A@MV8!qHQso*\">distance</field></block></value><value name=\"B\"><block type=\"math_number\" id=\"0zD~xiEA=cqeRCv4eaM~\"><field name=\"NUM\">5</field></block></value></block></value><statement name=\"DO0\"><block type=\"rgb_set_all\" id=\"{B7.4j0%k,iFvso8S{V+\"><field name=\"COLOR\">#ff0000</field></block></statement><next><block type=\"controls_if\" id=\"Xrg6Pn=eSC{|ik|cQ70/\"><value name=\"IF0\"><block type=\"logic_compare\" id=\"^S7k%G0GLgXyvBN[AW9:\"><field name=\"OP\">GT</field><value name=\"A\"><block type=\"variables_get\" id=\"M*q2i,$f{5@iS@(bca=l\"><field name=\"VAR\" id=\"Xt.Yi4F7A@MV8!qHQso*\">distance</field></block></value><value name=\"B\"><block type=\"math_number\" id=\"NgDsDdDI45!d]63@MdFx\"><field name=\"NUM\">5</field></block></value></block></value><statement name=\"DO0\"><block type=\"emoji_show\" id=\"!xJIcEN0rz|J7U0eK(di\"><field name=\"COLOR\">#33ff33</field><field name=\"MAP_0_0\">FALSE</field><field name=\"MAP_0_1\">FALSE</field><field name=\"MAP_0_2\">FALSE</field><field name=\"MAP_0_3\">TRUE</field><field name=\"MAP_0_4\">FALSE</field><field name=\"MAP_0_5\">FALSE</field><field name=\"MAP_0_6\">FALSE</field><field name=\"MAP_1_0\">FALSE</field><field name=\"MAP_1_1\">FALSE</field><field name=\"MAP_1_2\">FALSE</field><field name=\"MAP_1_3\">FALSE</field><field name=\"MAP_1_4\">TRUE</field><field name=\"MAP_1_5\">FALSE</field><field name=\"MAP_1_6\">FALSE</field><field name=\"MAP_2_0\">FALSE</field><field name=\"MAP_2_1\">FALSE</field><field name=\"MAP_2_2\">FALSE</field><field name=\"MAP_2_3\">FALSE</field><field name=\"MAP_2_4\">FALSE</field><field name=\"MAP_2_5\">TRUE</field><field name=\"MAP_2_6\">FALSE</field><field name=\"MAP_3_0\">TRUE</field><field name=\"MAP_3_1\">TRUE</field><field name=\"MAP_3_2\">TRUE</field><field name=\"MAP_3_3\">TRUE</field><field name=\"MAP_3_4\">TRUE</field><field name=\"MAP_3_5\">TRUE</field><field name=\"MAP_3_6\">TRUE</field><field name=\"MAP_4_0\">FALSE</field><field name=\"MAP_4_1\">FALSE</field><field name=\"MAP_4_2\">FALSE</field><field name=\"MAP_4_3\">FALSE</field><field name=\"MAP_4_4\">FALSE</field><field name=\"MAP_4_5\">TRUE</field><field name=\"MAP_4_6\">FALSE</field><field name=\"MAP_5_0\">FALSE</field><field name=\"MAP_5_1\">FALSE</field><field name=\"MAP_5_2\">FALSE</field><field name=\"MAP_5_3\">FALSE</field><field name=\"MAP_5_4\">TRUE</field><field name=\"MAP_5_5\">FALSE</field><field name=\"MAP_5_6\">FALSE</field><field name=\"MAP_6_0\">FALSE</field><field name=\"MAP_6_1\">FALSE</field><field name=\"MAP_6_2\">FALSE</field><field name=\"MAP_6_3\">TRUE</field><field name=\"MAP_6_4\">FALSE</field><field name=\"MAP_6_5\">FALSE</field><field name=\"MAP_6_6\">FALSE</field><next><block type=\"rgb_set_all\" id=\"Nj:;qVxN_LV~EUelnZY4\"><field name=\"COLOR\">#33cc00</field><next><block type=\"servo_unit_write_angle\" id=\"kYzd(74/{IeKMEXuH[3A\"><field name=\"VARNAME\">servo_0</field><value name=\"ANGLE\"><shadow type=\"math_number\" id=\"=tYvf!XZcPiK?d,klx:O\"><field name=\"NUM\">180</field></shadow></value><next><block type=\"timer_delay\" id=\"ykBA5dV1by$Dw#EL/)Lp\"><value name=\"DELAY\"><shadow type=\"math_number\" id=\"Dr/V.q(wzyY9?7n[HAR{\"><field name=\"NUM\">1</field></shadow></value></block></next></block></next></block></next></block></statement></block></next></block></next></block></next></block></statement></block></next></block><block type=\"button_callback\" id=\"ut@%YQUSIaJ-Eh[H=/Y`\" x=\"70\" y=\"130\"><field name=\"BUTTON\">C</field><field name=\"EVENT\">wasPressed</field><statement name=\"FUNC\"><block type=\"emoji_show\" id=\"_|d)vhN}DKdFG-EAbqZi\"><field name=\"COLOR\">#ff0000</field><field name=\"MAP_0_0\">FALSE</field><field name=\"MAP_0_1\">FALSE</field><field name=\"MAP_0_2\">FALSE</field><field name=\"MAP_0_3\">TRUE</field><field name=\"MAP_0_4\">FALSE</field><field name=\"MAP_0_5\">FALSE</field><field name=\"MAP_0_6\">FALSE</field><field name=\"MAP_1_0\">FALSE</field><field name=\"MAP_1_1\">FALSE</field><field name=\"MAP_1_2\">TRUE</field><field name=\"MAP_1_3\">FALSE</field><field name=\"MAP_1_4\">FALSE</field><field name=\"MAP_1_5\">FALSE</field><field name=\"MAP_1_6\">FALSE</field><field name=\"MAP_2_0\">FALSE</field><field name=\"MAP_2_1\">TRUE</field><field name=\"MAP_2_2\">FALSE</field><field name=\"MAP_2_3\">FALSE</field><field name=\"MAP_2_4\">FALSE</field><field name=\"MAP_2_5\">FALSE</field><field name=\"MAP_2_6\">FALSE</field><field name=\"MAP_3_0\">TRUE</field><field name=\"MAP_3_1\">TRUE</field><field name=\"MAP_3_2\">TRUE</field><field name=\"MAP_3_3\">TRUE</field><field name=\"MAP_3_4\">TRUE</field><field name=\"MAP_3_5\">TRUE</field><field name=\"MAP_3_6\">TRUE</field><field name=\"MAP_4_0\">FALSE</field><field name=\"MAP_4_1\">TRUE</field><field name=\"MAP_4_2\">FALSE</field><field name=\"MAP_4_3\">FALSE</field><field name=\"MAP_4_4\">FALSE</field><field name=\"MAP_4_5\">FALSE</field><field name=\"MAP_4_6\">FALSE</field><field name=\"MAP_5_0\">FALSE</field><field name=\"MAP_5_1\">FALSE</field><field name=\"MAP_5_2\">TRUE</field><field name=\"MAP_5_3\">FALSE</field><field name=\"MAP_5_4\">FALSE</field><field name=\"MAP_5_5\">FALSE</field><field name=\"MAP_5_6\">FALSE</field><field name=\"MAP_6_0\">FALSE</field><field name=\"MAP_6_1\">FALSE</field><field name=\"MAP_6_2\">FALSE</field><field name=\"MAP_6_3\">TRUE</field><field name=\"MAP_6_4\">FALSE</field><field name=\"MAP_6_5\">FALSE</field><field name=\"MAP_6_6\">FALSE</field><next><block type=\"servo_unit_write_angle\" id=\"x*tE4x_rd:l6/:M@X%4c\"><field name=\"VARNAME\">servo_0</field><value name=\"ANGLE\"><shadow type=\"math_number\" id=\"jK,BXE!S/pZJN_9klUcO\"><field name=\"NUM\">0</field></shadow></value><next><block type=\"timer_delay\" id=\"-9X{n)I=Ufs}Skf3kOf=\"><value name=\"DELAY\"><shadow type=\"math_number\" id=\"*tY]3)Ch`r41V$w.x?l+\"><field name=\"NUM\">1</field></shadow></value></block></next></block></next></block></statement></block>","Blockly.Remotes":[],"Blockly.RemotePlus":[{"id":"__title","blockId":"","createTime":1675181578994,"name":"M5RemoteTitle","dragAndDrop":false,"resizable":false,"options":{"minWidth":1,"minHeight":1,"maxWidth":6,"maxHeight":10,"defaultWidth":2,"defaultHeight":1},"w":2,"h":1,"bgColor":"#0080FF","color":"#fff","fontsize":"M","label":"M5Remote","interval":3000,"code":"","event":"","dataSource":"none","ezdataToken":"","topic":"","needShadow":false,"type":"title","x":0,"y":0}],"modules":["rgb"],"cbIdList_":[],"eventCBIdList_":[]}
Have questions or comments? Continue the conversation on TechForum, DigiKey's online community and technical resource.
Visit TechForum