Hi Guys im struggling here as this is my first ever Arduino project.
here is what i want to do.
i want to control a relay with progressive pulses starting from small pulses going to bigger ones and eventually a constant supply.
it must only operate while holding the button.
letting go of the push button should cancel the process entirely until you press and hold again.
process should only run while the button is being held otherwise it should not.
i manage it perfectly until i insert some pulses, as soon as i start doing pulses it runs through the entire code before it stops where as i want to interrupt it whenever i release the push button.
here is my current code:
*const int buttonPin = 2; // the number of the pushbutton pin*
*const int ledPin = 13; // the number of the LED pin*
*// variables will change:*
*int buttonState = 0; // variable for reading the pushbutton status*
*void setup() {*
* // initialize the LED pin as an output:*
* pinMode(ledPin, OUTPUT);*
* // initialize the pushbutton pin as an input:*
* pinMode(buttonPin, INPUT);*
*}*
*void loop() {*
* // read the state of the pushbutton value:*
* buttonState = digitalRead(buttonPin);*
* // check if the pushbutton is pressed. If it is, the buttonState is HIGH:*
* if (buttonState == HIGH) {*
* int buttonState = 0; *
* digitalWrite(ledPin, HIGH);*
* delay(25)*
* ;digitalWrite(ledPin, LOW);*
* delay(75)*
* ;digitalWrite(ledPin, HIGH);*
*delay(25)*
* ;digitalWrite(ledPin, LOW);*
* delay(75)*
* ;digitalWrite(ledPin, HIGH);*
* delay(25)*
* ;digitalWrite(ledPin, LOW);*
* delay(75)*
* ;digitalWrite(ledPin, HIGH);*
* delay(50)*
* ;digitalWrite(ledPin, LOW);*
* delay(50)*
* ;digitalWrite(ledPin, HIGH);*
* delay(50)*
* ;digitalWrite(ledPin, LOW);*
* delay(50)*
* ;digitalWrite(ledPin, HIGH);*
* delay(50)*
* ;digitalWrite(ledPin, LOW);*
* delay(50)*
* ;digitalWrite(ledPin, HIGH);*
* delay(75)*
* ;digitalWrite(ledPin, LOW);*
* delay(25)*
* ;digitalWrite(ledPin, HIGH);*
* delay(75)*
* ;digitalWrite(ledPin, LOW);*
* delay(25)*
* ;digitalWrite(ledPin, HIGH);*
* delay(75)*
* ;digitalWrite(ledPin, LOW);*
* delay(25)*
* ;digitalWrite(ledPin, HIGH);*
* delay(10000)*
* ;digitalWrite(ledPin, LOW);*
* delay(25)*
* ;digitalWrite(ledPin, HIGH);*
* } else {*
* // turn LED off:*
* digitalWrite(ledPin, LOW);*
* }*
*}*
any help will be appreciated