Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // CODE FOR MITCH
- #include <SimpleSDAudio.h>
- // constants won't change. They're used here to
- // set pin numbers:
- const int buttonPin = 2; // the number of the pushbutton pin
- const int ledPin = 13; // the number of the LED pin
- // variables will change:
- int buttonState = 0; // variable for reading the pushbutton status
- void setup()
- {
- // Open serial communications and wait for port to open:
- Serial.begin(9600);
- int sensorValue = analogRead(A0);
- while (!Serial) {
- ; // wait for serial port to connect. Needed for Leonardo only
- // initialize the LED pin as an output:
- pinMode(ledPin, OUTPUT);
- // initialize the pushbutton pin as an input:
- pinMode(buttonPin, INPUT);
- }
- // Using F("...") to avoid wasting RAM
- Serial.print(F("\nInitializing SD card..."));
- // If your SD card CS-Pin is not at Pin 4, enable and adapt the following line:
- // SdPlay.setSDCSPin(10);
- if (!SdPlay.init(SSDA_MODE_FULLRATE | SSDA_MODE_MONO | SSDA_MODE_AUTOWORKER)) {
- Serial.println(F("initialization failed. Things to check:"));
- Serial.println(F("* is a card is inserted?"));
- Serial.println(F("* Is your wiring correct?"));
- Serial.println(F("* maybe you need to change the chipSelect pin to match your shield or module?"));
- Serial.print(F("Error code: "));
- Serial.println(SdPlay.getLastError());
- while(1);
- } else {
- Serial.println(F("Wiring is correct and a card is present."));
- }
- Serial.print(F("Looking for CHUCK.AFM... "));
- if(!SdPlay.setFile("CHUCK.AFM")) {
- Serial.println(F(" not found on card! Error code: "));
- Serial.println(SdPlay.getLastError());
- while(1);
- } else {
- Serial.println(F("found."));
- }
- Serial.print(F("Playing... "));
- SdPlay.play();
- while(!SdPlay.isStopped()) {
- ; // no worker needed anymore :-)
- }
- Serial.println(F("done."));
- SdPlay.deInit();
- }
- void loop(void) {
- // read the state of the pushbutton value:
- buttonState = digitalRead(buttonPin);
- // check if the pushbutton is pressed.
- // if it is, the buttonState is HIGH:
- if (buttonState == HIGH) {
- // turn LED on:
- digitalWrite(ledPin, HIGH);
- }
- else {
- // turn LED off:
- digitalWrite(ledPin, LOW);
- }
- // Open serial communications and wait for port to open:
- Serial.begin(9600);
- int sensorValue = analogRead(A0);
- while (!Serial) {
- ; // wait for serial port to connect. Needed for Leonardo only
- }
- // Using F("...") to avoid wasting RAM
- Serial.print(F("\nInitializing SD card..."));
- // If your SD card CS-Pin is not at Pin 4, enable and adapt the following line:
- SdPlay.setSDCSPin(10);
- if (!SdPlay.init(SSDA_MODE_FULLRATE | SSDA_MODE_MONO | SSDA_MODE_AUTOWORKER)) {
- Serial.println(F("initialization failed. Things to check:"));
- Serial.println(F("* is a card is inserted?"));
- Serial.println(F("* Is your wiring correct?"));
- Serial.println(F("* maybe you need to change the chipSelect pin to match your shield or module?"));
- Serial.print(F("Error code: "));
- Serial.println(SdPlay.getLastError());
- while(1);
- } else {
- Serial.println(F("Wiring is correct and a card is present."));
- }
- Serial.print(F("Looking for CHUCK.AFM... "));
- if(!SdPlay.setFile("CHUCK.AFM")) {
- Serial.println(F(" not found on card! Error code: "));
- Serial.println(SdPlay.getLastError());
- while(1);
- } else {
- Serial.println(F("found."));
- }
- Serial.print(F("Playing... "));
- SdPlay.play();
- while(!SdPlay.isStopped()) {
- ; // no worker needed anymore :-)
- }
- Serial.println(F("done."));
- SdPlay.deInit();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement