//SN 220 Simplified version random number delay and Input Pullup //Arc welder simple with button configured with PULLUP //Paul and David Bradt modification /* Input Pull-up Serial This example demonstrates the use of pinMode(INPUT_PULLUP). It reads a digital input on pin 2 and prints the results to the Serial Monitor. The circuit: - On-Off Toggle switch attached from pin 2 to ground - LED-Resistor connected to Port 7 Unlike pinMode(INPUT), there is no pull-down resistor necessary. An internal 20K-ohm resistor is pulled to 5V. This configuration causes the input to read HIGH when the switch is open, and LOW when it is closed. Oringial INPUT serial developed: created 14 Mar 2012 by Scott Fitzgerald This example code is in the public domain. https://docs.arduino.cc/built-in-examples/digital/InputPullupSerial/ */ void setup() { //start serial connection Serial.begin(9600); //configure pin 2 as an input and enable the internal pull-up resistor pinMode(2, INPUT_PULLUP); pinMode(7, OUTPUT); } void loop() { //read the pushbutton value into a variable int sensorVal = digitalRead(2); //print out the value of the pushbutton Serial.println(sensorVal); // Keep in mind the pull-up means the pushbutton's logic is inverted. It goes // HIGH when it's open, and LOW when it's pressed. Turn on pin 13 when the // button's pressed, and off when it's not: if (sensorVal == HIGH) { digitalWrite(7, LOW); delay(random(30, 150)); digitalWrite(7, HIGH); delay(random(30, 50)); } else { digitalWrite(7, LOW); } }