{"id":5827,"date":"2021-10-27T18:50:56","date_gmt":"2021-10-27T18:50:56","guid":{"rendered":"https:\/\/netpipe.ca\/?page_id=5827"},"modified":"2021-10-27T23:06:27","modified_gmt":"2021-10-27T23:06:27","slug":"vending-machines","status":"publish","type":"page","link":"https:\/\/netpipe.ca\/?page_id=5827","title":{"rendered":"vending machines"},"content":{"rendered":"<p><strong>Vending Machines<\/strong><\/p>\n<hr \/>\n<p>Im Just getting started but it looks good sofar.<\/p>\n<p><a href=\"https:\/\/github.com\/netpipe\/coin_acceptor\">https:\/\/github.com\/netpipe\/coin_acceptor<\/a> &#8211; old code should update it soon<\/p>\n<p><a href=\"https:\/\/github.com\/netpipe\/OSMMAC\">https:\/\/github.com\/netpipe\/OSMMAC<\/a><\/p>\n<p><a href=\"https:\/\/www.thingiverse.com\/thing:3050863\">https:\/\/www.thingiverse.com\/thing:3050863<\/a><\/p>\n<p>&nbsp;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"\" src=\"https:\/\/i.ebayimg.com\/images\/g\/Oa8AAOSw6n5XqjYw\/s-l500.jpg\" width=\"270\" height=\"270\" \/> dc step up transformer works well for converting 5v to 12v for the coin acceptor<\/p>\n<ul>\n<li>Its nice to convert these things to 5v power with a wallwart so they are CSA approved and non fire hazard. I used underground networking cable (cat45E) which can supply 3 paired 2 amp lines,only needed one though.<\/li>\n<li>the motors spin easily on 5v and have enough oomph to not get stuck.<\/li>\n<li>be sure to have a vending licence unless your selling non food items and on your own property \/ lawn or shop otherwise you will need a direct seller licence to cover any liability&#8217;s.<\/li>\n<li>old vending machines without coin mechs or outdated ones can go for under 300 dollars, its nice to have the option to put electronic parts inside or jewlery \/ makeup i&#8217;ve even seen them selling steaks in them. also if you get one with a working coin mech they can be resold for part of the cost of buying the vending machine after replacing the insides.<\/li>\n<li><\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p><a href=\"https:\/\/netpipe.ca\/wp-content\/uploads\/2021\/10\/AQJT6533.resized-rotated.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-5828\" src=\"https:\/\/netpipe.ca\/wp-content\/uploads\/2021\/10\/AQJT6533.resized-225x300.jpg\" alt=\"\" width=\"225\" height=\"300\" srcset=\"https:\/\/netpipe.ca\/wp-content\/uploads\/2021\/10\/AQJT6533.resized-225x300.jpg 225w, https:\/\/netpipe.ca\/wp-content\/uploads\/2021\/10\/AQJT6533.resized-rotated.jpg 750w\" sizes=\"auto, (max-width: 225px) 100vw, 225px\" \/><\/a><a href=\"https:\/\/netpipe.ca\/wp-content\/uploads\/2021\/10\/IMG_0006.resized-rotated.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-5829\" src=\"https:\/\/netpipe.ca\/wp-content\/uploads\/2021\/10\/IMG_0006.resized-225x300.jpg\" alt=\"\" width=\"225\" height=\"300\" srcset=\"https:\/\/netpipe.ca\/wp-content\/uploads\/2021\/10\/IMG_0006.resized-225x300.jpg 225w, https:\/\/netpipe.ca\/wp-content\/uploads\/2021\/10\/IMG_0006.resized-rotated.jpg 750w\" sizes=\"auto, (max-width: 225px) 100vw, 225px\" \/><\/a><a href=\"https:\/\/netpipe.ca\/wp-content\/uploads\/2021\/10\/KMXN0394.resized-rotated.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-5830\" src=\"https:\/\/netpipe.ca\/wp-content\/uploads\/2021\/10\/KMXN0394.resized-225x300.jpg\" alt=\"\" width=\"225\" height=\"300\" srcset=\"https:\/\/netpipe.ca\/wp-content\/uploads\/2021\/10\/KMXN0394.resized-225x300.jpg 225w, https:\/\/netpipe.ca\/wp-content\/uploads\/2021\/10\/KMXN0394.resized-rotated.jpg 750w\" sizes=\"auto, (max-width: 225px) 100vw, 225px\" \/><\/a><a href=\"https:\/\/netpipe.ca\/wp-content\/uploads\/2021\/10\/IMG_0008.resized-rotated.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-5831\" src=\"https:\/\/netpipe.ca\/wp-content\/uploads\/2021\/10\/IMG_0008.resized-225x300.jpg\" alt=\"\" width=\"225\" height=\"300\" srcset=\"https:\/\/netpipe.ca\/wp-content\/uploads\/2021\/10\/IMG_0008.resized-225x300.jpg 225w, https:\/\/netpipe.ca\/wp-content\/uploads\/2021\/10\/IMG_0008.resized-rotated.jpg 750w\" sizes=\"auto, (max-width: 225px) 100vw, 225px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>ment to run on arduino due. , the nano 328 ran out of space or something. i&#8217;ve seen a more reliable version where they solder to the led&#8217;s on the coin acceptor instead of relying on code which can double the pulses or misfire without the ir sensor.<\/p>\n<blockquote><p>&nbsp;<\/p>\n<p>#include &lt;Adafruit_SSD1306-swire.h&gt;<br \/>\n#include &lt;Adafruit_GFX.h&gt;<br \/>\n\/\/ OLED display TWI address<br \/>\n#define OLED_ADDR 0x3C<br \/>\nAdafruit_SSD1306 display(-1);<\/p>\n<p>#if (SSD1306_LCDHEIGHT != 64)<br \/>\n#error(&#8220;Height incorrect, please fix Adafruit_SSD1306.h!&#8221;);<br \/>\n#endif<\/p>\n<p>#include &#8220;SWire.h&#8221;<br \/>\n#include &#8220;I2CKeyPad-swire.h&#8221;<\/p>\n<p>const uint8_t KEYPAD_ADDRESS = 0x38; \/\/38<\/p>\n<p>I2CKeyPad keyPad(KEYPAD_ADDRESS);<\/p>\n<p>uint32_t start, stop;<br \/>\nuint32_t lastKeyPressed = 0;<\/p>\n<p>char keys[] = &#8220;123A456B789C*0#DNF&#8221;; \/\/ N = Nokey, F = Fail<\/p>\n<p>\/\/#define IRSENSOR \/\/TCRT5000 IR SENSOR module from ebay hotglued to bottom of unit on left side and connected to D0<\/p>\n<p>\/\/20 , 40,70 ms with 100 ms between<br \/>\n\/\/#define SLOW 70<br \/>\n\/\/#define MEDIUM 40<br \/>\n#define FAST 20<\/p>\n<p>const int IRPIN = 3;<br \/>\nconst int COINPIN = 8;<\/p>\n<p>#ifdef MEDIUM<br \/>\nconst int threshold1 = 350; \/\/ higher value for larger sample window<br \/>\nconst int sampleWindow = 40; \/\/ Sample window width in mS (50 mS = 20Hz)<br \/>\n#endif<\/p>\n<p>#ifdef FAST<br \/>\nconst int threshold1 = 100; \/\/ higher value for larger sample window<br \/>\nconst int sampleWindow = 15; \/\/ Sample window width in mS (50 mS = 20Hz)<br \/>\n#endif<\/p>\n<p>int oldpulses=0;<br \/>\nint counter=0;<br \/>\nint sample;<br \/>\nint samplebuffer = 0;<br \/>\nint count=0; \/\/idle loop counter<br \/>\nfloat money = 0.0;<br \/>\nint pulses = 0;<br \/>\nuint32_t timeLastPulse = 0;<br \/>\n\/\/string pulsestring;<br \/>\nuint32_t startMillis;<br \/>\nuint32_t elapsedmilis=0;<br \/>\nuint32_t halfmilis=0;<br \/>\nuint32_t timeFromLastPulse;<br \/>\nint bpulse=0;<br \/>\nint oldcounter=0;<\/p>\n<p>&nbsp;<\/p>\n<p>void setup()<br \/>\n{<\/p>\n<p>Serial.begin(9600);<br \/>\n\/\/ Serial.println(__FILE__);<br \/>\npinMode(COINPIN,INPUT_PULLUP);<\/p>\n<p>display.begin(SSD1306_SWITCHCAPVCC, OLED_ADDR,1,A4,A5);<br \/>\ndisplay.clearDisplay();<br \/>\ndisplay.display();<\/p>\n<p>\/\/ display a line of text<br \/>\ndisplay.setTextSize(2);<br \/>\ndisplay.setTextColor(WHITE);<br \/>\ndisplay.setCursor(27,30);<br \/>\ndisplay.print(&#8220;Hello, world!&#8221;);<\/p>\n<p>\/\/ update display with all of the above graphics<br \/>\ndisplay.display();<\/p>\n<p>&nbsp;<\/p>\n<p>\/\/ delay(1500);<br \/>\n\/\/ SWire.begin(A4,A5);<br \/>\n\/\/ SWire.setClock(400000);<br \/>\nif (keyPad.begin(A4,A5) == false)<br \/>\n{<br \/>\nSerial.println(&#8220;\\nERROR: cannot communicate to keypad.\\nPlease reboot.\\n&#8221;);<br \/>\n\/\/ while(1);<br \/>\n}<\/p>\n<p>}<\/p>\n<p>void Keypad(){<br \/>\nif (startMillis &#8211; lastKeyPressed &gt;= 100)<br \/>\n{<br \/>\nlastKeyPressed = startMillis;<\/p>\n<p>start = micros();<br \/>\nuint8_t idx = keyPad.getKey();<br \/>\nstop = micros();<\/p>\n<p>Serial.print(millis());<br \/>\nSerial.print(&#8220;\\t&#8221;);<br \/>\nSerial.print(idx);<br \/>\nSerial.print(&#8220;\\t&#8221;);<br \/>\nSerial.print(keys[idx]);<br \/>\nSerial.print(&#8220;\\t&#8221;);<br \/>\nSerial.println(stop &#8211; start);<br \/>\n}<br \/>\n}<\/p>\n<p>void LCDupdate(){<br \/>\ndelay(400);<br \/>\ndisplay.clearDisplay();<br \/>\n\/\/ display a line of text<br \/>\ndisplay.setTextSize(5);<br \/>\ndisplay.setTextColor(WHITE);<br \/>\ndisplay.setCursor(27,30);<br \/>\n\/\/ String test2 = String(count) ;<br \/>\ndisplay.print( String(startMillis) );<\/p>\n<p>\/\/ update display with all of the above graphics<br \/>\ndisplay.display();<br \/>\n}<\/p>\n<p>void loop()<br \/>\n{<br \/>\nstartMillis= millis(); \/\/ Start of sample window<br \/>\n\/\/halfmilis=startMillis\/2-40;<\/p>\n<p>while (elapsedmilis &lt; sampleWindow)<br \/>\n{<\/p>\n<p>\/\/ #ifdef IRSENSOR<br \/>\n\/\/ if (bpulse &lt; 3 &amp;&amp; digitalRead(IRPIN) &lt; 1 ){<br \/>\n\/\/ bpulse++;<br \/>\n\/\/ \/\/ delay(5);<br \/>\n\/\/ }<br \/>\n\/\/ #endif<\/p>\n<p>if (digitalRead(COINPIN) &lt; 1)<br \/>\n{<br \/>\n\/\/ Serial.println(samplebuffer);<br \/>\nsamplebuffer++;<br \/>\n}<\/p>\n<p>elapsedmilis = millis() &#8211; startMillis;<br \/>\n}<\/p>\n<p>\/\/check thresholds<br \/>\nif (samplebuffer &gt;= threshold1)<br \/>\n{<br \/>\nSerial.println(samplebuffer);<br \/>\npulses++;<br \/>\n\/\/ pulsestring+=1;<br \/>\ntimeLastPulse = millis();<br \/>\ncount=0;<br \/>\ndelay (100);<br \/>\n}<\/p>\n<p>samplebuffer = 0;<br \/>\nelapsedmilis=0;<br \/>\ncount++;<\/p>\n<p>\/\/ #ifdef IRSENSOR<br \/>\n\/\/ if (bpulse &gt;= 3){<br \/>\n\/\/ \/\/ Serial.println(&#8220;IRPULSE2&#8221;);<br \/>\n\/\/ Serial.println(counter);<br \/>\n\/\/ counter++;<br \/>\n\/\/ bpulse=0;<br \/>\n\/\/ count=0;<br \/>\n\/\/ delay(16);<br \/>\n\/\/ }<br \/>\n\/\/ #endif<\/p>\n<p>timeFromLastPulse = millis() &#8211; timeLastPulse;<\/p>\n<p>if (pulses &gt; 0 &amp;&amp; timeFromLastPulse &gt; 150) \/\/set higher to be more accurate or if you are getting single and double pulse<br \/>\n{<br \/>\nswitch(pulses){<br \/>\n\/\/ single and double pulse available aswell but sometimes are triggered accidently when putting coins in fast<br \/>\n\/\/ might be ok to use with larger 100ms sample window now.<br \/>\ncase 3: {<br \/>\nSerial.println(&#8220;Received quarter (3 pulses)&#8221;);<br \/>\nSerial.println(counter);<br \/>\nmoney += .25;<br \/>\nbreak;<br \/>\n}<br \/>\ncase 6: {<br \/>\nSerial.println(&#8220;Received 50 cents (6 pulses)&#8221;);<br \/>\nSerial.println(counter);<br \/>\nmoney += .50;<br \/>\nbreak;<br \/>\n}<br \/>\ncase 9: {<br \/>\nSerial.println(&#8220;Received 75 cents (9 pulses)&#8221;);<br \/>\nSerial.println(counter);<br \/>\nmoney += .75;<br \/>\nbreak;<br \/>\n}<br \/>\ncase 4: { \/\/10 pulses<br \/>\nSerial.println(&#8220;Received looney (4 pulses)&#8221;);<br \/>\nSerial.println(counter);<br \/>\nmoney += 1.0;<br \/>\nbreak;<br \/>\n}<br \/>\ncase 8: {<br \/>\nSerial.println(&#8220;Received toonie (8 pulses)&#8221;);<br \/>\nSerial.println(counter);<br \/>\nmoney += 2.0;<br \/>\nbreak;<br \/>\n}<br \/>\ncase 7: {<br \/>\nSerial.println(&#8220;Received 1.25 (7 pulses)&#8221;);<br \/>\nmoney += 1.25;<br \/>\nbreak;<br \/>\n}<br \/>\ncase 10: {<br \/>\nSerial.println(&#8220;Received 1.50 (10 pulses)&#8221;);<br \/>\nmoney += 1.50;<br \/>\nbreak;<br \/>\n}<br \/>\ncase 11: {<br \/>\nSerial.println(&#8220;Received 2.25 (11 pulses)&#8221;);<br \/>\nmoney += 2.25;<br \/>\nbreak;<br \/>\n}<br \/>\ncase 12: {<br \/>\nSerial.println(&#8220;doozy&#8221;);<br \/>\nSerial.println(counter);<br \/>\nif (counter &lt; 4){<br \/>\nSerial.println(&#8220;Received 3.00 (12 pulses)&#8221;);<br \/>\nmoney += 3.00;<br \/>\n}<br \/>\nif (counter == 4){<br \/>\nSerial.println(&#8220;Received 3 quarters (12 pulses)&#8221;);<br \/>\nmoney += 1.00;<br \/>\n}<br \/>\nbreak;<br \/>\n}<br \/>\ncase 15: { \/\/ on nano i could only compile this many in<br \/>\nSerial.println(&#8220;Received 5quarters (16 pulses)&#8221;);<br \/>\nmoney += 1.25;<br \/>\nbreak;<br \/>\n}<br \/>\ncase 16: {<br \/>\nSerial.println(&#8220;Received 2tooney (16 pulses)&#8221;);<br \/>\nSerial.println(counter);<br \/>\nmoney += 4.0;<br \/>\nbreak;<br \/>\n}<br \/>\ncase 20: {<br \/>\nSerial.println(&#8220;Received 2tooney (20 pulses)&#8221;);<br \/>\nmoney += 3.0;<br \/>\nbreak;<br \/>\n}<br \/>\ncase 24: {<br \/>\nSerial.println(&#8220;Received 3tooney (24 pulses)&#8221;);<br \/>\nmoney += 6.0;<br \/>\nbreak;<br \/>\n}<br \/>\ndefault : {<br \/>\nSerial.print(&#8220;Unknown coin: &#8220;);<br \/>\nSerial.print(pulses);<br \/>\nSerial.println(&#8221; pulses&#8221;);<br \/>\nbreak;<br \/>\n}<br \/>\n} \/\/end switch<\/p>\n<p>counter=0;<br \/>\npulses = 0;<br \/>\ntimeFromLastPulse=0;<br \/>\ntimeLastPulse=0;<br \/>\noldpulses=0;<br \/>\nbpulse=0;<br \/>\noldcounter=0;<br \/>\ncount=0;<br \/>\n}else{<br \/>\nif (count &gt; 50) {<br \/>\n\/\/ Serial.println(&#8220;r&#8221;);<br \/>\noldcounter=0;<br \/>\ncounter=0;<br \/>\nbpulse=0;<br \/>\nif (count &gt; 600) {<br \/>\nSerial.println(&#8220;money&#8221;);<br \/>\nSerial.println(money);<br \/>\n\/\/ LCDupdate();<br \/>\n\/\/ Keypad();<br \/>\ncount=0;<br \/>\n}<br \/>\ndelay(4);<br \/>\n}<br \/>\ncount++;<br \/>\n} \/\/idle detector<\/p>\n<p>LCDupdate();<br \/>\nKeypad();<br \/>\n}<\/p>\n<p>\/\/ &#8212; END OF FILE &#8212;<\/p><\/blockquote>\n<p>&nbsp;<\/p>\n<p>savemco motor turners, put the old grounds into power then\u00a0 ground all the motors and use the irf540n pin to trigger the motor on and off.<\/p>\n<p><a href=\"https:\/\/netpipe.ca\/wp-content\/uploads\/2021\/10\/IMG_0023.resized.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-5840\" src=\"https:\/\/netpipe.ca\/wp-content\/uploads\/2021\/10\/IMG_0023.resized-300x225.jpg\" alt=\"\" width=\"300\" height=\"225\" srcset=\"https:\/\/netpipe.ca\/wp-content\/uploads\/2021\/10\/IMG_0023.resized-300x225.jpg 300w, https:\/\/netpipe.ca\/wp-content\/uploads\/2021\/10\/IMG_0023.resized-768x576.jpg 768w, https:\/\/netpipe.ca\/wp-content\/uploads\/2021\/10\/IMG_0023.resized.jpg 1000w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p><a href=\"https:\/\/netpipe.ca\/wp-content\/uploads\/2021\/10\/IMG_0012.resized-rotated.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-5841\" src=\"https:\/\/netpipe.ca\/wp-content\/uploads\/2021\/10\/IMG_0012.resized-225x300.jpg\" alt=\"\" width=\"225\" height=\"300\" srcset=\"https:\/\/netpipe.ca\/wp-content\/uploads\/2021\/10\/IMG_0012.resized-225x300.jpg 225w, https:\/\/netpipe.ca\/wp-content\/uploads\/2021\/10\/IMG_0012.resized-rotated.jpg 750w\" sizes=\"auto, (max-width: 225px) 100vw, 225px\" \/><\/a> <a href=\"https:\/\/netpipe.ca\/wp-content\/uploads\/2021\/10\/IMG_0021.resized-rotated.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-5842\" src=\"https:\/\/netpipe.ca\/wp-content\/uploads\/2021\/10\/IMG_0021.resized-225x300.jpg\" alt=\"\" width=\"225\" height=\"300\" srcset=\"https:\/\/netpipe.ca\/wp-content\/uploads\/2021\/10\/IMG_0021.resized-225x300.jpg 225w, https:\/\/netpipe.ca\/wp-content\/uploads\/2021\/10\/IMG_0021.resized-rotated.jpg 750w\" sizes=\"auto, (max-width: 225px) 100vw, 225px\" \/><\/a> saega vending machine motors only need a jumper pin from the motor to the D side, leave power constant to the O side in marker there<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Vending Machines Im Just getting started but it looks good sofar. https:\/\/github.com\/netpipe\/coin_acceptor &#8211; old code should update it soon https:\/\/github.com\/netpipe\/OSMMAC https:\/\/www.thingiverse.com\/thing:3050863 &nbsp; dc step up transformer works well for converting 5v to 12v for the coin acceptor Its nice to convert these things to 5v power with a wallwart so they are CSA approved and [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-5827","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/netpipe.ca\/index.php?rest_route=\/wp\/v2\/pages\/5827","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/netpipe.ca\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/netpipe.ca\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/netpipe.ca\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/netpipe.ca\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=5827"}],"version-history":[{"count":12,"href":"https:\/\/netpipe.ca\/index.php?rest_route=\/wp\/v2\/pages\/5827\/revisions"}],"predecessor-version":[{"id":5850,"href":"https:\/\/netpipe.ca\/index.php?rest_route=\/wp\/v2\/pages\/5827\/revisions\/5850"}],"wp:attachment":[{"href":"https:\/\/netpipe.ca\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=5827"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}