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: "Arduino Input Control"
- - Source Code compiled for: Arduino Pro Mini 3.3V
- - Source Code created on: 2024-04-10 07:01:15
- ********* Pleasedontcode.com **********/
- /****** SYSTEM REQUIREMENTS *****/
- /****** SYSTEM REQUIREMENT 1 *****/
- /* make joystick xy axis controled by 2 potentiometer */
- /* and 3 joy buttons */
- /****** END SYSTEM REQUIREMENTS *****/
- /****** DEFINITION OF LIBRARIES *****/
- #include <Arduino.h>
- /****** FUNCTION PROTOTYPES *****/
- void setup(void);
- void loop(void);
- /***** DEFINITION OF ANALOG INPUT PINS *****/
- const uint8_t X_axis_Potentiometer_PIN = A0;
- const uint8_t Y_axis_Potentiometer_PIN = A1;
- const uint8_t button1_Pin = 2;
- const uint8_t button2_Pin = 3;
- const uint8_t button3_Pin = 4;
- void setup(void)
- {
- // put your setup code here, to run once:
- pinMode(X_axis_Potentiometer_PIN, INPUT);
- pinMode(Y_axis_Potentiometer_PIN, INPUT);
- pinMode(button1_Pin, INPUT_PULLUP);
- pinMode(button2_Pin, INPUT_PULLUP);
- pinMode(button3_Pin, INPUT_PULLUP);
- }
- void loop(void)
- {
- // put your main code here, to run repeatedly:
- int x_axis_value = analogRead(X_axis_Potentiometer_PIN);
- int y_axis_value = analogRead(Y_axis_Potentiometer_PIN);
- // Use the analog input values to control the joystick
- // Your code to control the joystick goes here
- // Read the button states
- bool button1_state = digitalRead(button1_Pin);
- bool button2_state = digitalRead(button2_Pin);
- bool button3_state = digitalRead(button3_Pin);
- // Use the button states to control the buttons
- // Your code to control the buttons goes here
- delay(100); // Add a small delay to avoid reading the analog inputs too quickly
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement