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: Input Setup
- - Source Code compiled for: Arduino Uno
- - Source Code created on: 2024-03-17 18:42:47
- ********* Pleasedontcode.com **********/
- /****** SYSTEM REQUIREMENTS *****/
- /****** SYSTEM REQUIREMENT 1 *****/
- /* using Arduino Mega, 28byj-48, IR Speed sensor, I2C */
- /* LCD Display 16x2, forward limit switch, and */
- /* reverse limit switch. By creating a Navigation */
- /* menu through a rotary encoder(HW-040). */
- /****** END SYSTEM REQUIREMENTS *****/
- /****** DEFINITION OF LIBRARIES *****/
- #include <EasyButton.h> //https://github.com/evert-arias/EasyButton
- #include <Wire.h> // For I2C communication
- #include <LiquidCrystal_I2C.h> // For LCD display
- /****** FUNCTION PROTOTYPES *****/
- void setup(void);
- void loop(void);
- /***** DEFINITION OF DIGITAL INPUT PINS *****/
- const uint8_t button_PushButton_PIN_D2 = 2;
- const uint8_t limitSwitch_Forward_PIN = 3;
- const uint8_t limitSwitch_Reverse_PIN = 4;
- const uint8_t rotaryEncoder_CLK_PIN = 5;
- const uint8_t rotaryEncoder_DT_PIN = 6;
- const uint8_t rotaryEncoder_SW_PIN = 7;
- const uint8_t speedSensor_PIN = 8;
- /****** DEFINITION OF LIBRARIES CLASS INSTANCES *****/
- EasyButton button_PushButton(button_PushButton_PIN_D2);
- LiquidCrystal_I2C lcd(0x27, 16, 2); // I2C address 0x27, 16 columns, 2 rows
- void setup(void)
- {
- // put your setup code here, to run once:
- pinMode(button_PushButton_PIN_D2, INPUT_PULLUP);
- pinMode(limitSwitch_Forward_PIN, INPUT_PULLUP);
- pinMode(limitSwitch_Reverse_PIN, INPUT_PULLUP);
- pinMode(rotaryEncoder_CLK_PIN, INPUT_PULLUP);
- pinMode(rotaryEncoder_DT_PIN, INPUT_PULLUP);
- pinMode(rotaryEncoder_SW_PIN, INPUT_PULLUP);
- pinMode(speedSensor_PIN, INPUT);
- // Initialize the EasyButton object with the pin number
- button_PushButton.begin();
- // Initialize the LCD display
- lcd.begin(16, 2);
- lcd.setCursor(0, 0);
- lcd.print("Navigation Menu");
- }
- void loop(void)
- {
- // put your main code here, to run repeatedly:
- // Call the EasyButton read() function to check for button events
- if (button_PushButton.read())
- {
- // Button is pressed
- // Add your code here to handle the button press event
- }
- // Add your code here to read the other inputs and handle the navigation menu
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement