i have a problem i am writing a script that can controll
1 servo (automatic)
1 motor (automatic) full speed
1 motor (manual pwm)
3 leds that indicate the stage
it is a script for starting a jet engine
i will describe the procitiure
(remember the script isnt done yet)
all wit a * isnt scripted yet
power on
ignition on (will be scripted)
you turn the key (switch)
oilpump starts (motor)
w8 10 sec (delay)
*puts bypass open (servo)
open gas valve (servo)
w8 60 sec (delay) combustion chamber heats up
*closses bypass (servo)
w8 60 sec (delay) combustion camber gets hotter
closes valve 3/4 (servo) to keep the engine running
starts diesel pump (motor)
if you turn the key off (switch)
all varibles get reseted
oilpump remains on (motor)
60 sec delay (engine cools down)
oilpump shuts down
but the problem is
i cant get to controll the diesel pump motor
who could help me fix this problem
or clean up my scripting (that would be nice)
#include "Servo.h"
Servo myservo; // create servo object to control a servo
// constants won't change. They're used here to
// set pin numbers:
int motor = 10;
int sensorPin = 0; // select the input pin for the potentiometer
int sensorValue = 0; // variable to store the value coming from the sensor
const int buttonPin = 2; // the number of the pushbutton pin
const int ledPin = 12; // the number of the LED pin
const int ledPin1 = 13; // the number of the LED pin
const int ledPin2 = 14; // the number of the LED pin
const int transistorPin = 9; // connected to the base of the transistor
// variables will change:
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
void setup() {
// initialize the LED pin as an output:
pinMode(ledPin, OUTPUT);
// initialize the keybutton pin as an input:
pinMode(buttonPin, INPUT);
// attaches the servo on pin 2 to the servo object
myservo.attach(3);
// set the transistor pin as output:
pinMode(transistorPin, OUTPUT);
// set the motor pin as an output
analogWrite(motor, OUTPUT);
// set up Serial library at 9600 bps
Serial.begin(9600);
}
void loop(){
// read the state of the keybutton value:
buttonState = digitalRead(buttonPin);
// check if the keybutton is pressed.
// if it is, the buttonState is HIGH:
if (buttonState == HIGH) {
// turn LED on:
digitalWrite(ledPin, HIGH);
Serial.print("test");
//---------------------------------
//oil pump start cannot be removed
//---------------------------------
//checks if oil pump is on
if (inputVariable1 == 0){
//oil pump on
digitalWrite(transistorPin, HIGH);
//turns this part off
inputVariable1 = 1;
Serial.print("test2");
}
else {
// turn LED on:
digitalWrite(ledPin1, HIGH);
Serial.print("test3 ");
}
//---------------------------------
//starting sequence
//---------------------------------
if (inputVariable2 == 0){
//gas valve open
myservo.write(180);
// waits for the servo to get there
delay(15);
//gas valve open
delay(1000);
myservo.write(1);
// waits for the servo to get there
delay(15);
//turns this part off
inputVariable2 = 1;
}
else {
// turn LED on:
digitalWrite(ledPin2, HIGH);
//help
// read the value from the sensor:
sensorValue = analogRead(sensorPin);
sensorValue = map(sensorValue, 0, 1023, 0, 250);
analogWrite(motor, sensorValue);
//
//turns this part off
inputVariable2 = 1;
}
}
//if key goes away
else {
if (inputVariable2 == 1){
delay(100);
// turn LED off:
digitalWrite(ledPin, LOW);
digitalWrite(ledPin1, LOW);
digitalWrite(ledPin2, LOW);
inputVariable2 = 0; // zerro check
//---------------------------------
//oil pump stop cannot be removed
//---------------------------------
//checks if oil pump is on
if (inputVariable1 == 1){
// turn LED off:
digitalWrite(ledPin, LOW);
digitalWrite(ledPin1, LOW);
digitalWrite(ledPin2, LOW);
inputVariable2 = 0; // zerro check
Serial.print("blank ");
delay(10000);
//oil pump on
digitalWrite(transistorPin, LOW);
//turns this part off
inputVariable1 = 0;
Serial.print("test4");
}
else{
}
}
}
}
and remember this is my firsth script so it could look messy