Archives
Trending
Support
Login
clear text
XML
Django
JavaScript
MATLAB
C
C++
C#
Python
SQL
Shell
Bash
Markdown
YAML
JSON
HTML
CSS
PHP
Java
Ruby
Go
Rust
Swift
Kotlin
Arduino
TypeScript
Perl
Autohotkey
Lua
SQF
R
Scala
Haskell
Groovy
Dart
Clojure
VB.NET
Objective-C
PowerShell
Bash
CoffeeScript
Verilog
/********* Pleasedontcode.com ********** Pleasedontcode thanks you for automatic code generation! Enjoy your code! - Terms and Conditions: You have a non-exclusive, revocable, worldwide, royalty-free license for personal and commercial use. Attribution is optional; modifications are allowed, but you're responsible for code maintenance. We're not liable for any loss or damage. For full terms, please visit pleasedontcode.com/termsandconditions. - Project: Speed Control - Source Code NOT compiled for: Arduino Uno - Source Code created on: 2024-10-21 10:55:22 ********* Pleasedontcode.com **********/ /****** SYSTEM REQUIREMENTS *****/ /****** SYSTEM REQUIREMENT 1 *****/ /* Forward=A0 Reverse=A1 Dec=A2 Inc=A3 Speed=0 */ /* Inc is 3.2 volts when it changes to 1.5 volts for */ /* 1 second like denounce switch speed increment by 1 */ /****** END SYSTEM REQUIREMENTS *****/ /****** DEFINITION OF LIBRARIES *****/ #include
//https://github.com/evert-arias/EasyButton /****** FUNCTION PROTOTYPES *****/ void setup(void); void loop(void); /***** DEFINITION OF DIGITAL INPUT PINS *****/ const uint8_t A0_PushButton_PIN_D2 = 2; // Forward button const uint8_t A0_PushButton_PIN_D3 = 3; // Reverse button /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/ // Instance of the button for pin D2 (Forward) EasyButton buttonD2(A0_PushButton_PIN_D2); // Instance of the button for pin D3 (Reverse) EasyButton buttonD3(A0_PushButton_PIN_D3); // Variable to track speed increment int speedIncrement = 0; // Callback function to be called when the button on D2 is pressed for the given duration. void onPressedForDurationD2() { // Increment speed by 1 speedIncrement += 1; // Code to be executed when the button on D2 is pressed for the given duration. } // Callback function to be called when the button on D3 is pressed for the given duration. void onPressedForDurationD3() { // Decrement speed by 1 speedIncrement -= 1; // Code to be executed when the button on D3 is pressed for the given duration. } void setup(void) { // Initialize the buttons. buttonD2.begin(); buttonD3.begin(); // Add the callback function to be called when the button on D2 is pressed for at least the given time. buttonD2.onPressedFor(1000, onPressedForDurationD2); // 1 second for speed increment // Add the callback function to be called when the button on D3 is pressed for at least the given time. buttonD3.onPressedFor(1000, onPressedForDurationD3); // 1 second for speed decrement // Set the pin modes for the buttons. pinMode(A0_PushButton_PIN_D2, INPUT_PULLUP); pinMode(A0_PushButton_PIN_D3, INPUT_PULLUP); } void loop(void) { // Continuously read the status of the buttons. buttonD2.read(); buttonD3.read(); // Here you can add code to use the speedIncrement variable as needed } /* END CODE */
Mark as private (unlisted)
for 30 minutes
for 6 hours
for 1 day
for 1 week
for 1 month
for 1 year
everlasting (like CCCP)