need some guidance on codeing


i'm complete novice @ arduino micro controllers , have been given , assignment have write code suspension system requirements below, wrote basic code out see these parts work before add more variable code have written not operating way expecting , cannot figure out why appreciated. post code in next post window

software requirements
1.  if pot signal goes "out of range", eg > 4.75v or <0.25v deemed
to faulty , system should stop operating  , both outputs should
turn off.
2.  ideally system try maintain height of vehicle
approximately ½ way between min , max, typically pot value of
approx. 2.5v. if voltage less compressor should turn
on. if voltage greater exhaust value should turn on.
3.  hysteresis bands should added either size of 2.5v prevent
system switching rapidly.
4.  compressor run time should limited 5 minutes, in event of
an air leak in system compressor should not run continuously

const int senosorpin = a0;       // input pin pot sensor (pressure sensor) attached to
int sensorvalue = 0;             //value read pot sensor (pressure sensor)
const int compressor =13;        //output run signal compressor
const int exhaustvalve= 12;      //output run signal exhaust valve
const int ecufault = 11;         //output fault signal ecu

void setup() {                    // initialize output pins
pinmode(a0, input);               //reads pot value
pinmode(13, output);                //compressor run signal
pinmode(12, output);                //exhasut valve run/open signal
pinmode(11, output);                //fault output ecu


void loop() {

if(analogread(a0 >= 4.75)){         //pot value on range; fault
digitalwrite(13,0);                //compressor off
digitalwrite(12,0);                //valve off
digitalwrite(11,1);                //ecu fault on
}
if(analogread(a0 <= 0.25)){       //pot value under range; fault
digitalwrite(13,0);               //compressor off
digitalwrite(12,0);               //valve off
digitalwrite(11,1);               //ecu fault on
}
if(analogread(a0 >= 2.01 && a0 <= 3.99)){     //pot value ok
digitalwrite(13,0);                          //compressor off
digitalwrite(12,0);                          //valve off
digitalwrite(11,0);                          // ecu fault off
}
if(analogread(a0 >= 0.26 && a0 <= 2.0)){  //pot value low
digitalwrite(13,1);                    //compressor on
digitalwrite(12,0);                    //valve off
digitalwrite(11,0);                    //ecu fault off
//timer required count 5min , stop compressor
}
if(analogread(a0 >= 4.0 && a0 <=4.74)){        //pot value high
digitalwrite(13,0);               //compressor off
digitalwrite(12,1);              //valve on/open
digitalwrite(11,0);              // ecu fault off
}
delay(500);
}


Arduino Forum > Using Arduino > Project Guidance > need some guidance on codeing


arduino

Comments