ik weet niet wie het wil weten
ik heb hier de software en een schema
alles is geschreven voor de arduino
Code:
#include "Servo.h"
Servo gasservo; // create servo object to control a servo
Servo oilbypassservo; // create servo object to control a servo
// constants won't change. They're used here to
// set pin numbers:
int potPin = 0; // Analog pin 0 connected to the potentiometer
int dieselpumptransistorPin = 3; // connected from digital pin 9 to the base of the transistor
int potValue = 0; // value returned from the potentiometer
const int switchthatstartsPin = 4; // the number of the start button pin
const int keythatcontrollsallbuttonPin = 2; // the number of the pushbutton pin
const int powerledpin = 12; // the number of the LED pin
const int oilpumpledpin = 13; // the number of the LED pin
const int propaneinjectionledpin = 11; // the number of the LED pin
const int oilpumptransistorPin = 9; // connected to the base of the transistor
// variables will change:
// switch is connected to pin 2
int buttonState = 0; // variable for reading the keybutton status
int inputVariable1 = 0; // oil pump check
int inputVariable2 = 0; // start up check
int inputVariable3 = 0; // diesel check
int inputVariable4 = 0; // diesel pump check
int val; // variable for reading the pin status
int val2; // variable for reading the delayed/debounced status
int buttonState2 = 0; // variable to hold the button state
int lightMode = 0; // Is the light on or off?
void setup() {
// Set the switch pin as input
pinMode(switchthatstartsPin, INPUT);
// initialize the LED pin as an output:
pinMode(powerledpin, OUTPUT);
pinMode(oilpumpledpin, OUTPUT);
pinMode(propaneinjectionledpin, OUTPUT);
// initialize the keybutton pin as an input:
pinMode(keythatcontrollsallbuttonPin, INPUT);
// attaches the servo on pin 3 to the servo object
gasservo.attach(5);
// attaches the servo on pin 5 to the servo object
oilbypassservo.attach(6);
// set the transistor pin as output:
pinMode(oilpumptransistorPin, OUTPUT);
// set the motor pin as an output
pinMode(dieselpumptransistorPin, OUTPUT);
// set up Serial library at 9600 bps
Serial.begin(9600);
}
void loop()
{//0
// read the state of the keybutton value:
buttonState = digitalRead(keythatcontrollsallbuttonPin);
// check if the keybutton is pressed.
// if it is, the buttonState is HIGH:
if (buttonState == HIGH)
{//1
//---------------------------------
//diesel pump pwm routine
//---------------------------------
//checks if oil pump is on
if (inputVariable4 == 1)
{//
// read the value from the sensor:
potValue = analogRead(potPin) / 4; // read the potentiometer, convert it to between 0 - 255 for the value accepted by the digital pin.
analogWrite(dieselpumptransistorPin, potValue); // potValue alters the supply from pin 9 which in turn controls the power running through the transistor
//
Serial.print("test2");
}//
else
{//
}//
//---------------------------------
//start button check
//---------------------------------
// turn LED on:
digitalWrite(powerledpin, HIGH);
val = digitalRead(switchthatstartsPin); // read input value and store it in val
delay(10); // 10 milliseconds is a good amount of time
val2 = digitalRead(switchthatstartsPin); // read the input again to check for bounces
if (val == val2) { //2 // make sure we got 2 consistant readings!
if (val != buttonState2) { //3 // the button state has changed!
if (val == LOW) { //4 // check if the button is pressed
if (lightMode == 0) { //5 // is the light off?
lightMode = 1; // turn light on!
Serial.print("test");
//---------------------------------
//oil pump start cannot be removed
//---------------------------------
//checks if oil pump is on
if (inputVariable1 == 0)
{//6
//oil pump on
digitalWrite(oilpumptransistorPin, HIGH);
//turns this part off
inputVariable1 = 1;
delay(100);
// turn LED on:
digitalWrite(oilpumpledpin, HIGH);
Serial.print("test2");
}//6
else
{//7
}//7
//---------------------------------
//starting sequence
//---------------------------------
if (inputVariable2 == 0)
{//8
//oil bypass open
oilbypassservo.write(180);
//gas valve open
gasservo.write(180);
// waits for the servo to get there
delay(15);
//gas valve open
delay(1000);
oilbypassservo.write(1);
gasservo.write(25);
// waits for the servo to get there
delay(15);
//turns this part off
// turn LED on:
digitalWrite(propaneinjectionledpin, HIGH);
//turns this part off
inputVariable2 = 1;
delay(10);
inputVariable4 = 1;
}//8
else
{//9
}//9
} //5
else
{//10
lightMode = 0; // turn light off!
}//10
}//4
} //3
buttonState2 = val; // save the new state in our variable
}//2
}//1
//if key goes away
else
{//11
// turn LED off:
digitalWrite(powerledpin, LOW);
//---------------------------------
//oil pump stop cannot be removed
//---------------------------------
//checks if oil pump is on
if (inputVariable1 == 1)
{//13
// turn LED off:
digitalWrite(powerledpin, LOW);
digitalWrite(oilpumpledpin, LOW);
digitalWrite(propaneinjectionledpin, LOW);
inputVariable2 = 0; // zerro check
inputVariable4 = 0;
analogWrite(dieselpumptransistorPin, LOW);
Serial.print("blank ");
delay(10000);
//oil pump on
digitalWrite(oilpumptransistorPin, LOW);
//turns this part off
inputVariable1 = 0;
Serial.print("test4");
}//13
else
{//14
}//14
}//11
}//0