{"id":146,"date":"2019-12-28T12:12:44","date_gmt":"2019-12-28T06:42:44","guid":{"rendered":"http:\/\/vu3pyn.com\/?p=146"},"modified":"2023-05-18T23:14:09","modified_gmt":"2023-05-18T17:44:09","slug":"diy-spotwelder-for-lithium-battery-pack-building","status":"publish","type":"post","link":"https:\/\/vu3pyn.com\/index.php\/2019\/12\/28\/diy-spotwelder-for-lithium-battery-pack-building\/","title":{"rendered":"DIY SpotWelder for Lithium Battery Pack building"},"content":{"rendered":"\n<pre class=\"wp-block-code\"><code>\/*\nDisclaimers: The author is not responsible for any misuse of the information contained herein and accepts no responsibility\nfor any damage caused by the use or misuse of this information.\nCredits: This code has been taken from http:\/\/www.arduino.cc\/en\/Tutorial\/Debounce and modified for Spot Welding purpose.\n*\/\nint Allow_execution = LOW;\nconst int buttonPin = 3;   \nconst int RelayPin = 10;    \n\nint RelayState = LOW;       \nint buttonState;           \nint lastButtonState = LOW;   \nint delayontime = 0;\n\nunsigned long lastDebounceTime = 500;  \nunsigned long debounceDelay = 200;    \n\nint period = 40; \/** 40ms, changing this will keep the output ON for that many milliseconds *\/\nunsigned long time_now = 0;\n\nvoid setup() {\n  Serial.begin(9600);\n  pinMode(buttonPin, INPUT_PULLUP);\n  pinMode(RelayPin, OUTPUT);\n\n  digitalWrite(RelayPin, RelayState);\n  delay(500);\n  if(digitalRead(buttonPin) == HIGH)\n  {\n    Allow_execution = HIGH;\n    }\n}\n\nvoid loop() {\n  if(Allow_execution == HIGH)\n  {\n\n  int reading = digitalRead(buttonPin);\n\n  if (reading != lastButtonState) {\n    lastDebounceTime = millis();\n  }\n\n  if ((millis() - lastDebounceTime) > debounceDelay) {\n\n    if (reading != buttonState) {\n      buttonState = reading;\n\n      if (buttonState == LOW) {\n        RelayState = HIGH;\n        time_now = millis();\n        delayontime = millis();\n      }\n    }\n  }\n\n  digitalWrite(RelayPin, RelayState);\n\n  if(RelayState == HIGH)\n  {\n    if(millis() > time_now + period)\n    {\n     RelayState = LOW;\n     delayontime = millis() - delayontime;\n     Serial.print(delayontime);\n    }\n  }\n  \n  lastButtonState = reading;\n  }\n}<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"960\" height=\"720\" src=\"http:\/\/vu3pyn.com\/wp-content\/uploads\/2019\/12\/Spot-welder-Code-Flow.png\" alt=\"\" class=\"wp-image-149\" srcset=\"https:\/\/vu3pyn.com\/wp-content\/uploads\/2019\/12\/Spot-welder-Code-Flow.png 960w, https:\/\/vu3pyn.com\/wp-content\/uploads\/2019\/12\/Spot-welder-Code-Flow-300x225.png 300w, https:\/\/vu3pyn.com\/wp-content\/uploads\/2019\/12\/Spot-welder-Code-Flow-768x576.png 768w, https:\/\/vu3pyn.com\/wp-content\/uploads\/2019\/12\/Spot-welder-Code-Flow-720x540.png 720w\" sizes=\"auto, (max-width: 960px) 100vw, 960px\" \/><figcaption>Functional Flow for Spot Welder &#8211; millisecond delay<\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-embed-youtube wp-block-embed is-type-video is-provider-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n\t\t<div class=\"embed-privacy-container is-disabled embed-youtube\" data-embed-id=\"oembed_293e74f3e622e39d215bd50e83d2ef5a\" data-embed-provider=\"youtube\" style=\"aspect-ratio: 640\/360;\">\t\t\t\t\t\t<button type=\"button\" class=\"embed-privacy-enable screen-reader-text\">Display &quot;How to build Spot Welder with 12v car battery &#8211;  Lithium &#8211; Arduino&quot; from YouTube<\/button>\t\t\t<div class=\"embed-privacy-sr-message screen-reader-text\" role=\"status\" data-message=\"Content from YouTube has been loaded.\"><\/div>\t\t\t\t\t\t<div class=\"embed-privacy-overlay\">\t\t\t\t<div class=\"embed-privacy-inner\">\t\t\t\t\t<div class=\"embed-privacy-logo\" style=\"background-image: url(https:\/\/vu3pyn.com\/wp-content\/plugins\/embed-privacy\/assets\/images\/embed-youtube.png?ver=1.14.0);\" aria-hidden=\"true\"><\/div>\t\t<p>\t\t\tClick here to display content from YouTube.\t\t\t\t\t\t<br>\t\t\t\t\t\tLearn more in <a href=\"https:\/\/policies.google.com\/privacy?hl=en\" target=\"_blank\" rel=\"noopener noreferrer\">YouTube\u2019s privacy policy<span class=\"embed-privacy__new-tab-notice\"> (opens in a new tab)<\/span><\/a>.\t\t\t<noscript>\t\t\t\t<br>\t\t\t\tPlease enable JavaScript in your browser to load this content.\t\t\t<\/noscript>\t\t<\/p>\t\t<p class=\"embed-privacy-input-wrapper\">\t\t\t<input id=\"embed-privacy-store-youtube-293e74f3e622e39d215bd50e83d2ef5a\" type=\"checkbox\" value=\"1\" class=\"embed-privacy-input\" data-embed-provider=\"youtube\">\t\t\t<label for=\"embed-privacy-store-youtube-293e74f3e622e39d215bd50e83d2ef5a\" class=\"embed-privacy-label\" data-embed-provider=\"youtube\">\t\t\t\tAlways display content from YouTube\t\t\t<\/label>\t\t<\/p>\t\t\t\t\t\t<\/div>\t\t\t\t\t\t\t\t<div class=\"embed-privacy-footer\"><span class=\"embed-privacy-url\"><a href=\"https:\/\/youtu.be\/GoASyHo8730\">Open &quot;How to build Spot Welder with 12v car battery &#8211;  Lithium &#8211; Arduino&quot; directly<\/a><\/span><\/div>\t\t\t<\/div>\t\t\t\t\t\t<div class=\"embed-privacy-content\">\t\t\t\t<script>var _oembed_293e74f3e622e39d215bd50e83d2ef5a = '{\\\"embed\\\":\\\"&lt;iframe title=&quot;How to build Spot Welder with 12v car battery - Lithium - Arduino&quot; width=&quot;640&quot; height=&quot;360&quot; src=&quot;https:\\\\\/\\\\\/www.youtube-nocookie.com\\\\\/embed\\\\\/GoASyHo8730?feature=oembed&quot; frameborder=&quot;0&quot; allow=&quot;accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share&quot; referrerpolicy=&quot;strict-origin-when-cross-origin&quot; allowfullscreen&gt;&lt;\\\\\/iframe&gt;\\\"}';<\/script>\t\t\t<\/div>\t\t<\/div>\t\t\n<\/div><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":163,"comment_status":"open","ping_status":"open","sticky":true,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[],"class_list":["post-146","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-lithium-stuffs"],"_links":{"self":[{"href":"https:\/\/vu3pyn.com\/index.php\/wp-json\/wp\/v2\/posts\/146","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/vu3pyn.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/vu3pyn.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/vu3pyn.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/vu3pyn.com\/index.php\/wp-json\/wp\/v2\/comments?post=146"}],"version-history":[{"count":6,"href":"https:\/\/vu3pyn.com\/index.php\/wp-json\/wp\/v2\/posts\/146\/revisions"}],"predecessor-version":[{"id":156,"href":"https:\/\/vu3pyn.com\/index.php\/wp-json\/wp\/v2\/posts\/146\/revisions\/156"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/vu3pyn.com\/index.php\/wp-json\/wp\/v2\/media\/163"}],"wp:attachment":[{"href":"https:\/\/vu3pyn.com\/index.php\/wp-json\/wp\/v2\/media?parent=146"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/vu3pyn.com\/index.php\/wp-json\/wp\/v2\/categories?post=146"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/vu3pyn.com\/index.php\/wp-json\/wp\/v2\/tags?post=146"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}