Hi, im a biology student with zero arduino experience attempting to copy this program over to my arduino nano: http://softroboticstoolkit.com/low-cost-ep-circuit/board-implementation/software
Here is code:
void setup() {
// put your setup code here, to run once:
}
void loop() {
// put your main code here, to run repeatedly:
if ( switch_pin == HIGH) {
digitalWrite(inletValvePin,HIGH); // turn pressure valve HIGH
digitalWrite(pumpPin,HIGH); // make sure pump is on
digitalWrite(exhaustValvePin,LOW); // turn exhaust valve LOW
digitalWrite(ledPin,HIGH); // LED ON
}
if ( switch_pin == LOW) {
digitalWrite(inletValvePin,LOW); // turn pressure valve HIGH
digitalWrite(pumpPin,LOW); // pump is off
digitalWrite(exhaustValvePin,HIGH); // turn exhaust valve HIGH
digitalWrite(ledPin,LOW); // LED off
}
sensorValue = analogRead(analogInPin);
// digital value of pressure sensor voltage
voltage_mv = (sensorValue * reference_voltage_mv) / ADCFULLSCALE;
// pressure sensor voltage in mV
voltage_v = voltage_mv / 1000;
output_pressure = ( ( (voltage_v - (0.10 * (reference_voltage_mv/1000) )) * (Pmax - Pmin) ) / (0.8 * (reference_voltage_mv/1000) ) ) + Pmin;
if (sensorValue <= desiredValue) {
analogWrite(pumpPin,255); // Pump. (0 is off) and (255 is on)
digitalWrite(inletValvePin,HIGH); // open the air valve
digitalWrite(exhaustValvePin,LOW); // close the exhaust valve
}
if (sensorValue > desiredValue) {
while (analogRead(A0) > (desiredValue - tolerance) ) {
analogWrite(pumpPin,190); // reduce speed of pump
digitalWrite(inletValvePin,HIGH); // open the air valve
digitalWrite(exhaustValvePin,LOW); // close the exhaust valve
}
}
When i try to compile, i'm getting error message: exit status 1 'switch_pin' was not declared in this scope, for the second if statement line. Any idea what I'm doing incorrectly? Thanks in advance for the help.