/********* 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: pro1 - Source Code compiled for: Arduino Mega - Source Code created on: 2023-11-15 07:09:24 - Source Code generated by: Gopinath ********* Pleasedontcode.com **********/ /****** DEFINITION OF LIBRARIES *****/ #include #include /****** SYSTEM REQUIREMENT 1 *****/ /* turn on and turn off light of led should press the */ /* button */ /****** FUNCTION PROTOTYPES *****/ void setup(void); void loop(void); /***** DEFINITION OF SPI PINS *****/ const uint8_t butt1_SDCardModule_SPI_PIN_MOSI_D51 = 51; const uint8_t butt1_SDCardModule_SPI_PIN_MISO_D50 = 50; const uint8_t butt1_SDCardModule_SPI_PIN_SCLK_D52 = 52; const uint8_t butt1_SDCardModule_SPI_PIN_CS_D53 = 53; /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/ SdFat sd; // Instantiate SdFat object // Define button and LED pins const uint8_t buttonPin = 2; const uint8_t ledPin = 3; void setup(void) { pinMode(butt1_SDCardModule_SPI_PIN_CS_D53, OUTPUT); // start the SPI library: SPI.begin(); // Initialize SD card if (!sd.begin(butt1_SDCardModule_SPI_PIN_CS_D53, SD_SCK_MHZ(4))) { Serial.println("SD initialization failed."); while (1); } pinMode(buttonPin, INPUT); pinMode(ledPin, OUTPUT); } void loop(void) { // Check if the button is pressed if (digitalRead(buttonPin) == HIGH) { // Turn on the LED digitalWrite(ledPin, HIGH); } else { // Turn off the LED digitalWrite(ledPin, LOW); } }