Advertisement
kartonman

Arc Welder That Runs On Schedule

Aug 27th, 2021 (edited)
247
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.76 KB | None | 0 0
  1. /* Arc welder that operates at different intervals. Original sketch by by Gary Granai https://www.facebook.com/ModelSceneryTutorials with welding table contributed by Jim Weisenbach, Seattle, Washington, modified 29 August, 2021.
  2.  
  3. Full explanation of the sketch, including wiring diagram and video can be seen at WWWWWWW
  4.  
  5. A complete list of Arduino animation projects, all of which contain wiring diagrams and videos is at ZZZZZ
  6.  
  7. Use this sketch and modify it as you wish as long as all the information in this introduction is unchanged.
  8. */
  9.  
  10. #define ledPin 9 // LED connected to digital pin 9 //some people add a third with a blue tint.
  11. #define ledPin2 10 // LED connected to digital pin 9
  12. #define toggle 12
  13.  
  14. int weldingTable[][2] = {{1, 2}, {2, 1}}; // the left numbers are time on and the right time off. Change as you wish.
  15.  
  16. int i, j, count;
  17.  
  18. unsigned long offTimeDelay;
  19. unsigned long onTimeDelay;
  20.  
  21. long t1;
  22.  
  23. void setup() {
  24. pinMode(ledPin, OUTPUT);
  25. pinMode(ledPin2, OUTPUT);
  26. pinMode(toggle, INPUT_PULLUP);
  27. onTimeDelay = weldingTable[i][0] * 60000;
  28. offTimeDelay = weldingTable[i][1] * 60000;
  29.  
  30. }
  31.  
  32. void loop() {
  33.  
  34. if (digitalRead(toggle) == LOW) {
  35.  
  36. for (i = 0; i < 2; i++) {
  37. t1 = millis();
  38. while ((millis() - t1) < onTimeDelay) {
  39.  
  40.  
  41. count = random(10, 60);
  42. for (j = 0; j < count; j++) {
  43. digitalWrite(ledPin, HIGH);
  44. delay(random(80));
  45. digitalWrite(ledPin2, HIGH);
  46. delay(random(60));
  47. digitalWrite(ledPin, LOW);
  48. digitalWrite(ledPin2, LOW);
  49. delay(random(200));
  50. }
  51.  
  52. delay(random(800, 2000));
  53. }
  54.  
  55. t1 = millis();
  56.  
  57. while ((millis() - t1) < offTimeDelay);
  58. }
  59. }
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement