Hi, I am very new to Arduino coding and I am trying to make a solenoid valve code to run on an if..else statement. However, I keep getting errors like:
'solenoidPin1' was not declared in this scope. Here is my code so far, with an if else statement at the bottom. The
section is where I keep getting this error, and it appears again when I reference each valve in
full code:
Any help is greatly appreciated, I have tried everything I know, and could really use some guidance from someone more experienced.
'solenoidPin1' was not declared in this scope. Here is my code so far, with an if else statement at the bottom. The
Code:
void setup()
Code:
digitalWrite(solenoidPin1, LOW)
full code:
Code:
#include <Arduino.h>
#include <stdint.h>
int main(){
int solenoidPin1 = 1; //connected to Digital 1
int solenoidPin2 = 2; //connected to Digital 2
int solenoidPin3 = 3;
int solenoidPin4 = 4;
int solenoidPin5 = 5;
int solenoidPin6 = 6;
int solenoidPin7 = 7;
int solenoidPin8 = 8;
}
void setup() {
// put your setup code here, to run once:
pinMode(solenoidPin1, OUTPUT); //Sets the pin as an output
pinMode(solenoidPin2, OUTPUT); //Sets the pin as an output
pinMode(solenoidPin3, OUTPUT); //Sets the pin as an output
pinMode(solenoidPin4, OUTPUT); //Sets the pin as an output
pinMode(solenoidPin5, OUTPUT); //Sets the pin as an output
pinMode(solenoidPin6, OUTPUT); //Sets the pin as an output
pinMode(solenoidPin7, OUTPUT); //Sets the pin as an output
pinMode(solenoidPin8, OUTPUT); //Sets the pin as an output
}
void loop() {
// put your main code here, to run repeatedly:
if digitalWrite(solenoidPin1, HIGH){ //Switch Solenoid ON
delay(1000); //Wait 1 Second
digitalWrite(solenoidPin1, LOW); //Switch Solenoid ON
delay(1000); //Wait 1 Second
digitalWrite(solenoidPin6, HIGH);
delay(1000);
digitalWrite(solenoidPin6, LOW);
digitalWrite(solenoidPin7, HIGH);
delay(1000);
digitalWrite(solenoidPin7, LOW);
else digitalWrite(solenoidPin1, LOW);
}
}
Any help is greatly appreciated, I have tried everything I know, and could really use some guidance from someone more experienced.