Hi All,
My project is being triggered by static electricity.
While the UNO R3 board is energized running my sketch it will be triggered if I go near it, especially if I remove my jacket with fleece lining near it, 1' to 2' away. No kidding!
I provided a pic of setup and the sketch.
1)I tried coupling cap/resister connecting reset pin to ground on UNO.
2) Tried cap/resistor on buttonpin to ground on ONO.
Any thoughts?
// KOBE control Rev4
// This will sequence the ouputs after button press 1 and and a shutdown sequence on press 2:
const int buttonPin = 2; //assigns digital input 2 the name buttonPin
const int fan = 12; //assigns digital output 12 the name fan
const int pump = 11; //assigns digital output 11 the name pump
const int igniter = 10; //assigns digital output 10 the name igniter
const int cooldownled = 9; //assigns digital output 9 the name cooldownled
int x = 0; //sets x variable to 0 at start.
int buttonState = 0; // variables will change:
int oldButtonState = LOW;
void setup()
{
Serial.begin(9600); // start serial com at 9600 baud
while (! Serial); // Wait until Serial is ready
Serial.println("KOBE program started"); // print KOBE program started
oldButtonState = digitalRead(buttonPin);
pinMode(buttonPin, INPUT_PULLUP);
pinMode(fan, INPUT_PULLUP); //initalize as an input first so during power up it is not energized
pinMode(igniter, INPUT_PULLUP);
pinMode(pump, INPUT_PULLUP);
pinMode(cooldownled, INPUT_PULLUP);
// initialize the load pins as outputs
pinMode(fan, OUTPUT); // pin 12 // initialize the load pins as an output
pinMode(pump, OUTPUT); // pin 11
pinMode(igniter, OUTPUT); // pin 10
pinMode(cooldownled, OUTPUT); // pin 9
// initialize the pushbutton pin as an input:
pinMode(buttonPin, INPUT);
}
void loop()
{
// Get the current state of the button
int newButtonState = digitalRead(buttonPin);
// Has the button gone high since we last read it?
if (newButtonState == HIGH && oldButtonState == LOW) {
if (x == 0) {
Serial.println("button pressed"); // print button pressed
// Toggle on fan
Serial.println("fan on");
digitalWrite(fan, LOW); // turn on fan
delay(5000); // delay xxxx sec
// Toggle on pump
Serial.println("pump on");
digitalWrite(pump, LOW); // turn on pump
delay(0); // delay xxxx sec
// Toggle on igniter
Serial.println("igniter on");
digitalWrite(igniter, LOW); // turn on ignition relay active low
delay(5000); // ignition on time xxxx sec
digitalWrite(igniter, HIGH); // turn off ignition
Serial.println("igniter off");
Serial.println("Run mode entered");
x = 1; // toggle PButton state indicator to 1
} else { // if pump is on turn off and enter cool down mode
// shut down sequence
digitalWrite(pump, HIGH); // turn off pump
Serial.println("pump off");
digitalWrite(cooldownled, LOW); // turn on cool down led
Serial.println("cool down led on");
delay(5000);
digitalWrite(fan, HIGH); // turn off fan
digitalWrite(cooldownled, HIGH); // turn off cool down led
Serial.println("Heater off");
x = 0; // toggle PButton state indicator to 0
}
}
// Store the button's state so we can tell if it's changed next time around
oldButtonState = newButtonState;
}
