Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /********* 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: Button Control
- - Source Code compiled for: Arduino Uno
- - Source Code created on: 2024-03-11 11:24:38
- ********* Pleasedontcode.com **********/
- /****** SYSTEM REQUIREMENTS *****/
- /****** SYSTEM REQUIREMENT 1 *****/
- /* I want to use two relays for the left and right of */
- /* a tilt motor. Inside this motor, there is a 10 */
- /* kOhm potentiometer, which changes the position of */
- /* this motor according to the command that is being */
- /* executed. I will divide the right side of this */
- /* engin */
- /****** END SYSTEM REQUIREMENTS *****/
- /****** DEFINITION OF LIBRARIES *****/
- #include <EasyButton.h> //https://github.com/evert-arias/EasyButton
- /****** FUNCTION PROTOTYPES *****/
- void setup(void);
- void loop(void);
- /***** DEFINITION OF DIGITAL INPUT PINS *****/
- const uint8_t Btn1_PushButton_PIN_D2 = 2;
- const uint8_t Btn2_PushButton_PIN_D3 = 3;
- /***** DEFINITION OF ANALOG INPUT PINS *****/
- const uint8_t Pot_Potentiometer_Vout_PIN_A0 = A0;
- /****** DEFINITION OF LIBRARY CLASS INSTANCES*****/
- EasyButton Btn1_PushButton(Btn1_PushButton_PIN_D2);
- EasyButton Btn2_PushButton(Btn2_PushButton_PIN_D3);
- void setup(void)
- {
- // put your setup code here, to run once:
- pinMode(Btn1_PushButton_PIN_D2, INPUT_PULLUP);
- pinMode(Btn2_PushButton_PIN_D3, INPUT_PULLUP);
- pinMode(Pot_Potentiometer_Vout_PIN_A0, INPUT);
- }
- void loop(void)
- {
- // put your main code here, to run repeatedly:
- // Check the state of Btn1_PushButton
- Btn1_PushButton.read();
- if (Btn1_PushButton.isPressed())
- {
- // Perform the left tilt motor action
- }
- // Check the state of Btn2_PushButton
- Btn2_PushButton.read();
- if (Btn2_PushButton.isPressed())
- {
- // Perform the right tilt motor action
- }
- // Read the value of the potentiometer
- int potValue = analogRead(Pot_Potentiometer_Vout_PIN_A0);
- // Perform actions based on the potentiometer value
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement