I have my code configured to when I press a button it turns on a fan for so long then the motor comes on, I have it on a timer for it to shut off, but I would like to be able to turn it off any time during the process. What do I need to do in order for this to work.
This is my code:
int fan = 6;
int button = 2;
int motor = 7;
int buttonState = 0;
void setup() {
// put your setup code here, to run once:
pinMode(motor, OUTPUT);
pinMode(fan, OUTPUT);
pinMode(button, INPUT);
}
Please read the post at the start of any forum , entitled "How to use this Forum".
OR http://forum.arduino.cc/index.php/topic,148850.0.html.
Then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.
Hi,
First you need to adjust your code so that you start the sequence when the button state CHANGES from LOW to HIGH, rather than sensing that the button is high.
Have you got a pull_down 10K resistor between the buttonPin 2 and gnd?