Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* 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.
- Full explanation of the sketch, including wiring diagram and video can be seen at WWWWWWW
- A complete list of Arduino animation projects, all of which contain wiring diagrams and videos is at ZZZZZ
- Use this sketch and modify it as you wish as long as all the information in this introduction is unchanged.
- */
- #define ledPin 9 // LED connected to digital pin 9 //some people add a third with a blue tint.
- #define ledPin2 10 // LED connected to digital pin 9
- #define toggle 12
- int weldingTable[][2] = {{1, 2}, {2, 1}}; // the left numbers are time on and the right time off. Change as you wish.
- int i, j, count;
- unsigned long offTimeDelay;
- unsigned long onTimeDelay;
- long t1;
- void setup() {
- pinMode(ledPin, OUTPUT);
- pinMode(ledPin2, OUTPUT);
- pinMode(toggle, INPUT_PULLUP);
- onTimeDelay = weldingTable[i][0] * 60000;
- offTimeDelay = weldingTable[i][1] * 60000;
- }
- void loop() {
- if (digitalRead(toggle) == LOW) {
- for (i = 0; i < 2; i++) {
- t1 = millis();
- while ((millis() - t1) < onTimeDelay) {
- count = random(10, 60);
- for (j = 0; j < count; j++) {
- digitalWrite(ledPin, HIGH);
- delay(random(80));
- digitalWrite(ledPin2, HIGH);
- delay(random(60));
- digitalWrite(ledPin, LOW);
- digitalWrite(ledPin2, LOW);
- delay(random(200));
- }
- delay(random(800, 2000));
- }
- t1 = millis();
- while ((millis() - t1) < offTimeDelay);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement