Today I have been testing a module for Arduino that I had bought on Ebay and I also tried the Micro SD reader located in Arduino’s Ethernet Shield. To do this I made a simple code that writes every 5s the value of a potentiometer connected to the Arduino board in a file called “VALORPOT.TXT” (If this file doesn’t exist It is created and if It already exist the data is added after the existing one).
The modules I used were the following:
- MICRO SD Card Adapter bought on Ebay (there are also similar modules available on Dealextreme).
- Arduino Ethernet Shield.
Depending on the module and the type of Arduino board that we use we have to make some connections or other:
· For the ethernet module is only necessary to fit it correctly on the Arduino board and connect the potentiometer to the analog Pin 0.
· In the case of the MICRO SD CARD Adapter module is required to make the following connections:
- MOSI –> Pin 11 (Most Arduino boards), for Arduino Mega: 51
– MISO –> Pin 12 (Most Arduino boards), for Arduino Mega: 50
– CLK —-> Pin 13 (Most Arduino boards), for Arduino Mega: 52
– CS ——> Pin 4
– 5V ——> 5V
– GND –> GND
– Potentiometer connected to analog Pin 0
More information in http://arduino.cc/en/Reference/SPI
The program with corresponding explanations (comments in the code) is the following:
In the SD card a file called VALORPOT.TXT will be created whose content will look like this:
In the next post I will explain how to read data from a SD with Arduino.
Sources: Arduino SD Library