Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Design Application Development And Administration

Authors: Mannino Michael

5th Edition

0983332401, 978-0983332404

More Books

Students also viewed these Databases questions

Question

=+1.5. 1 The Cantor set C can be defined as the closure of A3(1).

Answered: 1 week ago