{"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<iframe loading=\"lazy\" title=\"How to build Spot Welder with 12v car battery -  Lithium - Arduino\" width=\"640\" height=\"360\" src=\"https:\/\/www.youtube.com\/embed\/GoASyHo8730?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe>\n<\/div><\/figure>\n\n\n\n<p><\/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}]}}