Question
int solenoidState=0; const int solenoidPin=7; const int on_buttonPin=3; const int off_buttonPin=13; int buttonNew; int buttonOld=0; int dt=10; void setup() { // put your setup code
int solenoidState=0; const int solenoidPin=7; const int on_buttonPin=3; const int off_buttonPin=13; int buttonNew; int buttonOld=0; int dt=10;
void setup() { // put your setup code here, to run once: Serial.begin(9600); pinMode(solenoidPin,OUTPUT); pinMode(off_buttonPin,INPUT); pinMode(on_buttonPin,INPUT); }
void loop() { // put your main code here, to run repeatedly: buttonNew=digitalRead(on_buttonPin); //if(buttonOld==1 && buttonNew==0){ if(solenoidState==1){ Serial.println("solenoid on"); digitalWrite(solenoidPin,HIGH); solenoidState=1; } else{ buttonNew=digitalRead(off_buttonPin); Serial.println("solenoid off"); digitalWrite(solenoid in,LOW); solenoidState=0; } //} buttonOld=buttonNew; delay(dt); } I am needing assistance, I am using a No Voltage Release (NVR) Switch (where the button is normally closed so when the button is pressed it is then open) to control the led 12v solenoid(voltage regulator on its way). I am trying to turn on the solenoid with one button and turn it off with the other button.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started