Greetings all,
Apologies in advance if this is not the correct place to post this, but I need some help on a circuit I need for a school project.
I'm following the tutorial here the circuit is just about the same. In my application I have a 12V solenoid valve instead of a DC motor. I have also changed the code to the following,
/*
*/
// verify that these pins are correct for the variable names
int pushButton = 2;
int valveControl = 13;
void setup()
{
// put your setup code here, to run once:
pinMode(pushButton, INPUT);
pinMode(valveControl, OUTPUT);
}
void loop()
{
// put your main code here, to run repeatedly:
if(digitalRead(pushButton == HIGH))
{
digitalWrite(valveControl, HIGH);
delay(10);
digitalWrite(valveControl, LOW);
}
else
{
digitalWrite(valveControl, LOW);
}
delay(3000);
}
I tried using TinkerCad to simulate the circuit before building it, but the issue I am having is that it appears PIN 2 is constantly having a 5V input despite the switch being in place to open the circuit. Meaning that the valve would just be opening and closing regardless of the push button being pressed. If anyone could look at my circuit or code and please help me understand where I have made my mistake I would greatly appreciate it. Thank you
TinkerCad link: Login | Tinkercad
This will allow you to edit the simulation just FYI.