Skip to content

Commit

Permalink
arduino code updated
Browse files Browse the repository at this point in the history
  • Loading branch information
smukkejohan committed Oct 14, 2012
1 parent 95c46aa commit 0c3055a
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 18 deletions.
36 changes: 29 additions & 7 deletions arduino/chaos_flowcontrol/chaos_flowcontrol.ino
Original file line number Diff line number Diff line change
@@ -1,22 +1,44 @@
#define CHANNEL_NUM 5

int incomingByte = 0; // for incoming serial data

int state = 2; //0 = auto 1 = pending 2 = controlled
long autoDelay = 400;
long lastContact = 0;

int channels [3];
int channels [CHANNEL_NUM];

float waterPressure [CHANNEL_NUM];
boolean waterValveOpen [CHANNEL_NUM];
boolean airValveOpen [CHANNEL_NUM];
float airPressure [CHANNEL_NUM];

float waterPressure [];
int waterValvePins [CHANNEL_NUM];
int airValvePins [CHANNEL_NUM];
int pumpPins [CHANNEL_NUM];
int airRegulatorPins [CHANNEL_NUM];

// syntax
// 2 W 1.0


void setup() {
Serial.begin(9600); // opens serial port, sets data rate to 9600 bps



Serial.begin(9600); // opens serial port, sets data rate to 9600 bps

waterValvePins[0] = 1;
waterValvePins[1] = 2;
waterValvePins[2] = 3;

airValvePins[0] = 1;
airValvePins[1] = 2;
airValvePins[2] = 3;

pumpPins[0] = 1;
pumpPins[1] = 2;
pumpPins[2] = 3;

airRegulatorPins[0] = 1;
airRegulatorPins[1] = 2;
airRegulatorPins[2] = 3;
}

void loop() {
Expand Down
28 changes: 17 additions & 11 deletions arduino/chaos_flowcontrol/control.ino
Original file line number Diff line number Diff line change
@@ -1,26 +1,32 @@

void setAirPressure(int channel, float value) {
// takes channel number and pressure
//analogWrite();
airPressure[channel] = value;
analogWrite(airRegulatorPins[channel], map(value, 0, 1, 0, 255));
}

void setWaterPressure(int channel, float value) {

waterPressure[channel] = value;
analogWrite(pumpPins[channel], map(value, 0, 1, 0, 255));
}

void waterValve() {

void openWater(int channel) {
waterValveOpen[channel] = true;
digitalWrite(waterValvePins[channel], HIGH);
}

void closeWater() {

void closeWater(int channel) {
waterValveOpen[channel] = false;
digitalWrite(waterValvePins[channel], LOW);
}

void openAir() {

void openAir(int channel) {
airValveOpen[channel] = true;
digitalWrite(airValvePins[channel], HIGH);
}

void closeAir() {

void closeAir(int channel) {
airValveOpen[channel] = false;
digitalWrite(airValvePins[channel], LOW);
}


0 comments on commit 0c3055a

Please sign in to comment.