Hi guys, i've a problem. I've made a sheme with 3 OneWire devices DS18B20 and a self made microSD shield. An idea is - find all OneWire devices, register them in a table, ask each one 1 time in 5 seconds 12 times and print data to a serial port (port monitor of Arduino IDE) and to a file on microSD card. If i comment a part of program which write data to a file, all the devices are found, table and temperature data from them printed to a serial. When i try to write it parallel to microSD, programm write "error opening test.txt", BUT! if the file was not on microSD card, it magically appears with 0b size. If i try to write a simple data with a simple programm to a microSD card like "test 1, 2, 3" whithout any changing in wiring it works great. File appears, data writing to it and so on. Please help me, I'll be glad for any suggestion.A simple programm, works great:

void setup(){ Serial.begin(9600); Serial.print("Initializing SD card..."); // On the Ethernet Shield, CS is pin 4. It's set as an output by default. // Note that even if it's not used as the CS pin, the hardware SS pin // (10 on most Arduino boards, 53 on the Mega) must be left as an output // or the SD library functions will not work. pinMode(10, OUTPUT);

/*while devices appears, i find they addresses and write to a matrix whith 10 strings, so i use up to 10 devises in my programm*/while (ds.search(address)){for ( i = 0; i < 8; i++) addressmap[k][i]=address[i];k=k+1; }//remember number of OneWire devicesdevicenum = k-1;

// On the Ethernet Shield, CS is pin 4. It's set as an output by default. // Note that even if it's not used as the CS pin, the hardware SS pin // (10 on most Arduino boards, 53 on the Mega) must be left as an output // or the SD library functions will not work

myFile can be evaluated as a logical expression - as in "(myfile)" - because the C++ compiler will treat any non-zero value as 'true'. So a NULL pointer (typically zero) will evaluate as false, although I would prefer to explicitly use "pointer == NULL". By comparing "myFile != false" the expression is only logically true if myFile is not equal to the value false (and I don't know what it is). Maybe changing this to the same logic as the simpler example could make a difference.

To GoForSmokeThank you for your answer. The simple programm write "testing 1, 2, 3" many times. +1 each time i turn on Arduino or call a serial port monitor (port monitor of Arduino IDE).Srting of code

To everyone.Thank you very much for your answers. Excuse me, I badly know the English language, and do not understand all of what you write here. I'm from Russia. With your help and help of my friend I found a solution, a bit strange in my opinion.

/*while devices appears, i find they addresses and write to a matrix whith 10 strings, so i use up to 10 devises in my programm*/while (ds.search(address)){for ( i = 0; i < 8; i++) addressmap[k][i]=address[i];k=k+1; }//remember number of OneWire devicesdevicenum = k-1;

// On the Ethernet Shield, CS is pin 4. It's set as an output by default. // Note that even if it's not used as the CS pin, the hardware SS pin // (10 on most Arduino boards, 53 on the Mega) must be left as an output // or the SD library functions will not work

There are some examples using micro-SD to full size adapter sleeve clear up to old-type floppy drive cable.

Of much interest is going from 5V Arduino to 3.3V SD. One way is to use 3.3V Arduino!

Best I have seen uses 3.3V supply (different ways of getting that) with pullups and diodes on the signal lines. When the 5V line is LOW the diode lets current through, the SD pin is LOW.When the 5V line is HIGH the diode blocks 5V and the 3.3V pullup holds the SD pin 3.3V HIGH.

What I like most with that is the 5V lines are not bleeding current through voltage dividers when they are HIGH.

With SD, I went with 1 voltage divider on the power line, change 5V to 3.3V. That same one also powers the pullups.

Sorry about using English. I am typical only know English American. I did take French class but that ended in 1972.I hope you have friends to help translate and how good it must be not stuck with just one language!