1

I am recieving SD card failuer and I did everything I could.

I use the correct SPI pins;

CS > 10
MOSI > 11
MISO > 12
SCK > 13
VCC > 5v
GND > GND

I did format my SD card to FAT32

I did write;

pinMode(csPin, OUTPUT);
digitalWrite(csPin, HIGH);

and I did add a blank file to sd card.

pls make harambe live ;-;

here is my code;

#include <pcmConfig.h>
#include <pcmRF.h>
#include <TMRpcm.h>
#include <SD.h>
#define sd_pin 10
TMRpcm tmr;

int speaker_pin = 3;
int trig_pin = 8;
int echo_pin = 9;
int buzzer_pin = 6;
long cm;
long lecture_echo;

void setup()
{
  Serial.begin(9600);
  Serial.println("active");

  pinMode(10, OUTPUT);
  digitalWrite(10, HIGH);
  
  if(!SD.begin(sd_pin)){
    Serial.println("harambe is dead");
    return;
  }
  else{
    Serial.println("harambe is alive");
  }
  
  tmr.speakerPin = speaker_pin;
  
  pinMode(echo_pin, INPUT);
  digitalWrite(trig_pin, LOW);
  pinMode(trig_pin, OUTPUT);
  
  pinMode(buzzer_pin, OUTPUT);
  
  
}

void loop() 
{
  digitalWrite(trig_pin, HIGH);
  delay(100);
  digitalWrite(trig_pin, LOW);
  
  lecture_echo = pulseIn(echo_pin, HIGH); 
  cm = lecture_echo / 58; 
  
  Serial.println(cm);
  delay(500);


  if(cm < 4)
    {
      
    }
  else
    {
      tmr.setVolume(5);
      tmr.play("test");
    }
}

8
  • run the SDCardInfo example
    – Juraj
    Commented Aug 13, 2020 at 18:15
  • k wait, it failed
    – neikami
    Commented Aug 13, 2020 at 18:40
  • What hardware are you using? How is it wired?
    – Majenko
    Commented Aug 13, 2020 at 20:02
  • laptop, is normaly wired
    – neikami
    Commented Aug 13, 2020 at 21:09
  • it is not a magic fix, but is a diagnostic tool. it prints what failed. so what did it print?
    – Juraj
    Commented Aug 14, 2020 at 5:02

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.