0

I need to work with SD card and TCRT5000 sensor (Reflective Optical Sensor with Transistor Output) and save data from sensor to file. So I select Arduino Uno and added to it a SD card shield(from LC STUDIO) and a TCRT5000 sensor but it isn't working. My circuit and code is here: enter image description here

#include <SPI.h>
#include <SD.h>

const int chipSelect = 10;

void setup() {
  Serial.begin(9600);
  pinMode(chipSelect, OUTPUT);
  if (!SD.begin(chipSelect)) {
    Serial.println("Card failed, or not present");
    while(true);
  }
  Serial.println("card initialized.");
  File dataFile = SD.open("test.txt", FILE_WRITE);
  dataFile.close();
  dataFile = SD.open("test.txt", FILE_WRITE);
  if(dataFile){
    dataFile.println("Start:");
  }else{
    Serial.println("Error in creating file.");
    while(true);
  }
}

void loop() {
  float value = analogRead(A3);
  File dataFile = SD.open("test.txt", FILE_WRITE);
  if (dataFile) {
    dataFile.println(value);
    Serial.println(value);
    dataFile.close();
  }else{
    Serial.println("Error in opening file.");
  }
  delay(5);
}

When TCRT5000 isn't connected SD card working without any problem. I think it is related to current and supply current. Any idea?

5
  • 1
    I would like to believe that you made a mistake with +5 and GND from board???
    – Martynas
    Commented Oct 17, 2014 at 10:56
  • 60mA can not do any problem. Maybe you connected it wrong? 90% problems are in wiring :))
    – Martynas
    Commented Oct 17, 2014 at 11:30
  • I checked it again. The circuit isn't wrong. I do it like this and this. If problem is not related to current,it is related to what? Why the SD card work when I remove TCRT5000 from circuit without any change in wiring?
    – Ahmad
    Commented Oct 17, 2014 at 14:03
  • Try disconnecting only D+. That way you know if the problem is with the IR-diode or the phototransistor.
    – Gerben
    Commented Oct 17, 2014 at 17:21
  • 1
    The 5V to the breadboard power rails is 100% not in the right spot. Both the 5V and GND are in the same rail, causing a short. I assume this is just an error in the diagram, like @Martynas said? Commented Dec 5, 2014 at 22:42

1 Answer 1

1

Did you figure this out yet? If not, you have the +5 volts going to the GND on the breadboard, causing a short.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.