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 Setup"
- - Source Code compiled for: Arduino Uno
- - Source Code created on: 2024-01-01 18:25:40
- ********* Pleasedontcode.com **********/
- /****** SYSTEM REQUIREMENTS *****/
- /****** SYSTEM REQUIREMENT 1 *****/
- /* Send midi data */
- /****** SYSTEM REQUIREMENT 2 *****/
- /* Write code that records data from a potentiometer */
- /* onto an SD card. The data will be saved in a text */
- /* file */
- /****** END SYSTEM REQUIREMENTS *****/
- /****** DEFINITION OF LIBRARIES *****/
- #include <Arduino.h>
- #include <SPI.h>
- #include <EasyButton.h>
- #include <SdFat.h>
- /****** FUNCTION PROTOTYPES *****/
- void setup(void);
- void loop(void);
- /***** DEFINITION OF DIGITAL INPUT PINS *****/
- const uint8_t Btn1_PushButton_PIN_D2 = 2;
- /***** DEFINITION OF ANALOG INPUT PINS *****/
- const uint8_t Pot1_Potentiometer_Vout_PIN_A0 = A0;
- /***** DEFINITION OF SPI PINS *****/
- const uint8_t Sdrw_SDCardModule_SPI_PIN_MOSI_D11 = 11;
- const uint8_t Sdrw_SDCardModule_SPI_PIN_MISO_D12 = 12;
- const uint8_t Sdrw_SDCardModule_SPI_PIN_SCLK_D13 = 13;
- const uint8_t Sdrw_SDCardModule_SPI_PIN_CS_D10 = 10;
- /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
- EasyButton button(Btn1_PushButton_PIN_D2, true, false); // Initialize the EasyButton object with the button pin
- SdFat sd; // Initialize the SdFat library object
- void setup(void)
- {
- // put your setup code here, to run once:
- Serial.begin(9600);
- pinMode(Btn1_PushButton_PIN_D2, INPUT_PULLUP);
- pinMode(Pot1_Potentiometer_Vout_PIN_A0, INPUT);
- pinMode(Sdrw_SDCardModule_SPI_PIN_CS_D10, OUTPUT);
- // start the SPI library:
- SPI.begin();
- button.begin(); // Initialize the button object
- button.onPressed([]() {
- // Button has been pressed callback function
- Serial.println("Button has been pressed");
- });
- if (!sd.begin(Sdrw_SDCardModule_SPI_PIN_CS_D10, SPI_FULL_SPEED)) {
- // Error initializing SD card
- Serial.println("SD card initialization failed");
- while (1)
- ;
- }
- }
- void loop(void)
- {
- // put your main code here, to run repeatedly:
- button.update(); // Update the button state
- // Rest of your code
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement