Hello all. I posted under the project guidance section a few days ago but figured this would be the best place to troubleshoot my code. If you can please take a look, I'd greatly appreciate it. Thank you.
http://arduino.cc/forum/index.php/topic,95400.0.html
/*
* Ignition & Throttle Valve Program
*/
const int triggerPin = 10; // Trigger is connected to pin 2
int val = LOW; // Variable for reading trigger status (float)
const int pizoPin = 9; // Pizeo Speaker is connected to pin 9
const int valvePin = 3; // Valve is connected to PWM pin 3
const int ignitorPin = 11; // Ignitor is connected to pin 11
const int dumppin = 13; // Dump switch is connected to pin 13
int val = LOW; // Variable for reading trigger status (float)
void setup() {
pinMode(triggerPin, INPUT); // Set the trigger pin as input
pinMode(valvePin, OUTPUT); // Set the switch pin as input
pinMode(ignitorPin, OUTPUT); // Set the switch pin as input
pinMode(pizoPin, OUTPUT); // Set the switch pin as input
pinMode(dumppin, INPUT); // Set the switch pin as input
}
void loop(){
analogWrite(pizoPin, 255); //Turn on pizo speaker for 3 seconds every 15 seconds to verify microcontroller is on
delay(3000);
analogWrite(pizoPin, 0);
delay(15000);
val = digitalRead(dumppin); // Read dump trigger input value and store it in val
if (val == HIGH) { // Check if dump trigger has been tripped
analogWrite(valvePin, 255); // Open valve and dump N20
delay(15000); // Wait for 15 seconds
analogWrite(valvePin, 0); // Close valve
val = digitalRead(triggerPin); // Read trigger input value and store it in val
if (val == HIGH) { // Check if trigger has been tripped
analogWrite(ignitorPin, 255); // Ignite ignitor
delay(1500); // Wait for 1.5 seconds
analogWrite(ignitorPin, 0); //
analogWrite(valvePin, 255); // Open valve 100%
delay(2000); // Wait for 2 seconds
analogWrite(valvePin, 179); // Open valve 70%
delay(10000); // Wait for 10 seconds
while (1) {
analogWrite(valvePin, 0); // Close valve
}
}
}