Skip to content
All gists
Back to GitHub
Sign in
Sign up
Sign in
Sign up
{{ message }}
Instantly share code, notes, and snippets.
Will-Firgelli
/
momentary-push-button-control.ino
Last active
Feb 26, 2020
Star
0
Fork
0
Star
Code
Revisions
2
Embed
What would you like to do?
Embed
Embed this gist in your website.
Share
Copy sharable link for this gist.
Clone via HTTPS
Clone with Git or checkout with SVN using the repository’s web address.
Learn more about clone URLs
Download ZIP
Raw
momentary-push-button-control.ino
/*
Firgelli Automations
* Limited or no support: we do not have the resources for Arduino code support
*
* Program enables momentary direction control of actuator using push button
*/
int
RPWM =
10
;
//
connect Arduino pin 10 to IBT-2 pin RPWM
int
LPWM =
11
;
//
connect Arduino pin 11 to IBT-2 pin LPWM
int
downPin =
12
;
int
upPin =
13
;
int
Speed =
255
;
//
choose any speed in the range [0, 255]
void
setup
() {
pinMode
(RPWM, OUTPUT);
pinMode
(LPWM, OUTPUT);
pinMode
(downPin, INPUT_PULLUP);
pinMode
(upPin, INPUT_PULLUP);
}
void
loop
() {
if
(
digitalRead
(upPin)==LOW){
//
check if extension button is pressed
analogWrite
(RPWM,
0
);
analogWrite
(LPWM, Speed);
}
else
if
(
digitalRead
(downPin)==LOW){
//
check if retraction button is pressed
analogWrite
(RPWM, Speed);
analogWrite
(LPWM,
0
);
}
else
{
//
if no button is pushed, remain stationary
analogWrite
(RPWM,
0
);
analogWrite
(LPWM,
0
);
}
}
Sign up for free
to join this conversation on GitHub
. Already have an account?
Sign in to comment
You can’t perform that action at this time.
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.