arduino lcd module sd card reader free sample
There are different models from different suppliers, but they all work in a similar way, using the SPI communication protocol. The module used in this tutorial is the one shown in figure below (front and back view).
This line of code creates a file called data.txt on your SD card. If the data.txt file already exists, Arduino will open the file instead of creating another one.
This example shows how to read and write data to and from an SD card.In setup(), create a new file with SD.open() named "test.txt". FILE_WRITE enables read and write access to the file, starting at the end. If a file "test.txt" was already on the card, that file would be opened.
Again, open the file with SD.open(). Once opened, ask the Arduino to read the contents of the file with SD.read() and send them over the serial port. After all the contents of the file are read, close the file with SD.close().
Note that pin 4 is default Chip Select (CS) pin for most boards. To set CS for MKR Zero, you can use 28 instead of 4, alt. use the SDCARD_SS_PIN definition.
This example shows how to read information about a SD card. The example reports volume type, free space and other information using the SD library, sending it over the serial port.
On the SD card, there is a file named "datalog.txt". In theloop(), the file is opened when calling SD.open(). To send the file serially to a computer, use Serial.print(), reading the contents of the file with SD.read().
In thesetup(), open a new file with SD.open() named "example.txt". FILE_WRITE enables read and write access to the file, starting at the end. In this example though, immediately close the file by calling myFile.close().
The mainloop() does nothing because the function that prints out the file directory of "/" of the SD card is called from the setup(). This because we need to see it just once.
Storing data is one of the most important parts of every project. There are several ways to store data according to the data type and size. SD and micro SD cards are one of the most practical ones among the storage devices, which are used in devices such as mobile phones, minicomputers and etc.
The SD and micro SD card modules allow you to communicate with the memory card and write or read the information on them. The module interfaces in the SPI protocol.
NoteThese modules can not handle high-capacity memory cards. Usually, the maximum identifiable capacity of these modules is 2GB for SD cards, and 16GB for micro SD cards.
What’s Next?Create an entry/exit control device. Using the RFID module and Arduino, save entrance and exit time for several persons on the memory card. (Consider an RFID card for each person)
The Arduino TFT screen is a backlit TFT LCD screen with a micro SD card slot in the back. You can draw text, images, and shapes to the screen with the TFT library.
The Arduino TFT library extends the Adafruit GFX, and Adafruit ST7735 libraries that it is based on. The GFX library is responsible for the drawing routines, while the ST7735 library is specific to the screen on the Arduino screen. The Arduino specific additions were designed to work as similarly to the Processing API as possible.
The TFT library relies on the SPI library, which must be included in any sketch that uses the scree. If you wish to use the SD card, you need to include the SD library as well.
By default, the screen is oriented so it is wider than it is tall. The top of the screen is the same side as the text "SD CARD"". In this orientation, the screen is 160 pixels wide and 128 pixels high.
The screen can be configured for use in two ways. One is to use an Arduino"s hardware SPI interface. The other is to declare all the pins manually. There is no difference in the functionality of the screen between the two methods, but using hardware SPI is significantly faster when drawing.
There is a socket on the front of the Esplora for the screen. Insert the screen into the socket with the blue tab that says "SD Card" closest to the USB port.
To give the illusion of motion, you need to quickly erase and draw images on the screen. When using Processing on a powerful computer, you can callbackground() every time through your draw() function to erase the window contests and dra objects in their new positions. The Arduino is not as fast, is it takes a little time to clear the screen when calling background() with the TFT library.
The TFT library has the ability to read .bmp files off a SD card and display them on the screen. Images can be smaller or larger than the screen resolution (160x128), but there is no method on the Arduino for image manipulation. The images should be sized before you put them on the SD card.
In the following example, a bitmap that is 160x128 pixels named "arduino.bmp" is in the root directory of a SD card. When read by the library and drawn, the image will fill the screen.
In addition to the libraries you have been including to this point, you will also need to include the SD library. You"ll also need to declare a CS pin for the SD slot.
Even if the screen"s headers are designed to fit into the socket on the front of the Arduino Esplora or the Arduino Robot but, this module is compatible with any AVR-based Arduino (UNO, Leonardo, etc...) or with the Arduino Due. If you want to use one these other boards, some slight changes on connections are required.
Connecting the pins in the proper way, you can see the lcd screen working with your Uno (or Duemilanove) just uploading the simple "TFTBitmapLogo" sketch.
The Arduino Leonardo & Arduino Yún use different pins to be compatible with the lcd screen. To set the pins MISO, MOSI and SCK, you have to use the ICSP terminals.+5V:+5V
The screen will show this message: "Arduino TFT Bitmap Example. Open serial monitor to run the sketch". Open the serial monitor to view the Arduino Logo.
To connect the lcd screen to an Arduino Due, use this pin configuration and don"t forget to set the right value for the variable "sd_cs" (#definesd_cs7) in the sketch:+5V:+3.3V
Secure Digital, or SD, Cards are used in a variety of applications. You likely have several of them in your electronic devices as they are used in phones, tablets, cameras, and music players.
Anywhere that you need a large amount of inexpensive, non-volatile memory an SD (or microSD) card is a good choice. And, as you are about to see, these cards are very easy to use in your Arduino projects.
The SD card was developed as a joint effort between SanDisk, Panasonic, and Toshiba. The first SD cards were released in August 1999. In January 2000 the three companies formed theSD Associationto create standards for SD cards.
There are actually three sizes of SD cards – standard SD cards, miniSD cards, and microSD cards. The miniSD card was never that popular and hasn’t been produced since 2008 so modern devices make use of either standard SD cards or microSD cards.
There are also a number of designations on SD cards such as “SDXC”, SDUC”, “UHS-I”, “Class 10” etc. This can get a bit confusing when trying to choose an SD card.
SD Cards have evolved to use different file systems, different speeds, and different connection methods than the original 1999 design. These differences are designated into five different storage classes:
SD cards are serial data cards and thus have limits to the speed that they can transfer data. As SD cards evolved so has their speeds and there are new designations to determine which cards are faster than others.
Older cards used a Class designation from 1 to 10, with a 10 being the fastest. Modern SD cards can all exceed Class 10 speed so the class designation is virtually meaningless.
A standard SD card uses the SPI bus and works at 3.3 volts. SDHC and SDXC cards can also switch to the “one-bit SD bus” and in this mode they work on 1.8 volts.
When an SDHC or SDXC card is inserted into its socket it will initially use the SPI bus. The host computer can switch the device to one-bit mode if the device supports it.
SD cards and microSD cards are electrically compatible, however, they do not use the same pinouts. The plastic “SD Adapter” that is usually included with microSD cards is wired to reconfigure the pinout so the microSD card can also be used in an SD card slot.
There are many SD card modules available for the Arduino. Some of them are stand-alone, others are shields. Many of the shields also have additional components like real time clocks, Ethernet adapters and temperature sensors integrated along with the SD card holder.
The SD card uses 3.3-volt logic so there is a built-in voltage regulator to reduce the 5-volt supply to 3.3-volts. If you use a 3.3-volt supply the regulator is bypassed.
One thing to note is that many of these modules do not have logic-level converters and therefore expect that 3.3-volt logic will be used. If you are using 5-volt logic, as with an Arduino Uno or Mega, you’ll need to supply logic-level converters or use a resistor array to work with the 3.3-volt logic.
These modules are made to be used with 5-volt logic as they contain built-in logic converters, as well as voltage regulators. As such they have only a 5-volt power input.
I’ll be showing you the connections using a microSD module but they are pretty well identical for a full-sized SD module. Remember though that if you elect to use a full-sized module you may need to do some logic-level conversion, otherwise your data will be garbled.
If you are using a shield with an SD or microSD card you might need to change the Chip Select (CS) pin connection, the one I have connected to pin 4. Some shields use pin 6 or pin 10, check with your shield manufacturer or use a multimeter to determine if this is the case with your shield
The Arduino IDE already has alibrary for working with SD cards. It supports both FAT16 and FAT32 file systems on both standard SD (SDSC) or SDHC cards. Keep that in mind if you are reformatting your microSD card and don’t use exFAT.
You can access these libraries by opening theFilemenu and selectingExamples. From the sub-menu scroll down until you get to theSDentry and highlight that. You’ll see six example sketches that you can try.
In the Setup we set the speed for the serial monitor and then write “Initializing SD card…” to it. We then initialize the SD card and print an error message if it fails.
Note the line withSD.begin(4)in it. The number “4” is the pin that the Chip Select (CS) of the module is connected to. If you’re using a shield which uses a different pin you’ll need to change this line to the proper value.
TheSD.openopens the file. We specify the file name and then we add theFILE_WRITEparameter to indicate that we want to write to the file. If we hadn’t specified that the file would be open to read instead.
Compile the sketch and send it to your Arduino, make sure that you have a microSD card in your module and that it is formatted with the FAT32 file system. Then open your serial monitor.
Try pressing the reset button on your Arduino and observe the serial monitor. You should see an additional line of text every time you press the button. This is because the sketch is appending the text to the file every time it is run.
The SD library has a simple Datalogger example. Unlike a professional datalogger, this one does not use a real time clock to add a timestamp to the data, it simply reads the data and writes it to a file on the SD card.
The wiper of each potentiometer is connected to one of the Arduino analog input pins, A0, A1, and A2. One side of each pot is connected to the 5-volt output, the other side is connected to ground.
This will allow you to vary the voltage sent to the analog pins from zero to 5 volts. We will measure the voltage and write the value, from 0 to 1023, to the SD card. The results will be saved in a comma-delimited file.
The Datalogger sketch starts off in a similar fashion to the previous example. You’ll note that a constant namedchipSelectis assigned to the pin you are using to connect to the CD line on your module. Again, if you are using a shield that connects CS to a different pin you’ll need to adjust that accordingly.
Load the sketch to your Arduino and open your serial monitor. You will see the values of the three analog inputs displayed, adjust some of the potentiometers and observe how they change.
After running it for a while power down the Arduino and remove the card. Now insert the card into your computer and read the resulting file. You should see it contains the same data you observed on the serial monitor.
Reading the file on your computer is useful but not as convenient as using the Arduino to do it. The final example we will take a look at will read the file to the Arduino serial monitor.
The DumpFile sketch dumps the contents of the file on the SD card to the serial monitor. As with the first example it works entirely in the Setup routine so there is no code in the loop.
You will also need a servo motor, along with a power supply for that motor. Although you could hook the servo up to the Arduino 5-volt output I really don’t recommend it, as sharing a servo with the Arduino power supply isn’t a very good idea – it can induce noise and voltage drops onto the supply lines.
I’ve created two sketches, one that records the servo data onto the SD card and a second one that plays it back. You could expand upon them and include them both in the same sketch, perhaps with some record and playback pushbuttons.
The sketch starts by including libraries for the SPI bus, the SD card module and for the servo motor. All three libraries are part of your Arduino IDE so you don’t need to install anything.
As you can see it is very simple to incorporate SD cards and microSD cards into your Arduino designs. By using them you can add a huge amount of non-volatile storage to your projects.
SD and microSD cards are a simple way to add huge amounts of non-volatile storage to your Arduino designs. In this article, I will show you how to use SD card modules with the Arduino. I will also show you how to record and playback the motion of a servo motor.
Description: The Arduino Graphic LCD (GLCD) screen is a backlit TFT LCD screen with headers. You can draw text, images, and shapes to the screen with the GLCD library. There is an onboard micro-SD card slot on the back of the screen that can, among other things, store bitmap images for the screen to display.
The screen"s headers are designed to fit into the socket on the front of the Arduino Esplora, but it is compatible with any AVR-based Arduino (Uno, Leonardo, etc. Datasheet You can use this module with Arduino Esplora.
In this Arduino Tutorial we will learn how to use an SD Card module with the Arduino Board. Also in combination with the DS3231 Real Time Clock module we will make a data logging example where we will store the data of a temperature sensor to the SD Card and import it into Excel to make a chart out of it. You can watch the following video or read the written tutorial below.
First let’s take a look at the SD Card Module. It works with standard MicroSD Cards which operating voltage is 3.3 V. Therefore, the module has a voltage regulator and a level shifter so that we can use it with the 5 V pins of the Arduino Board.
The SD Card Module have six pins, two for powering the module, the VCC and the GND pins, and four more pins for the SPI communication. Here’s how we need to connect it to the Arduino Board.
Code description:So first we need to include the standard SD and SPI libraries, create a “File” object and define the ChipSelect pin of the SPI bus, the pin 53 in my case for the Arduino Mega Board. For this example we want our code to be executed only once, so all the code will be placed in the “setup” section, while the “loop” section will remain empty.
So first we need to start the serial communication and define the ChipSelect pin as output. We have to do this because the ChipSelect pin needs to be “Low” so that the SPI communication between the module and the Arduino works.
Next, using the SD.begin() function we will initialize the SD card and if initialization is successful the “if” statement will become true and the String “SD card is ready to use.” will be printed on the serial monitor, else the string “SD card initialization failed” will be printed and also the program will be terminated.
Next, using the SD.open() function we will create a new file named “test.txt”, including the FILE_WRITE argument meaning that we can both read and write to the file. If the file already exist the SD.open() function will just open it.
So if the file has been successfully created first we will print the string “Writing to file” on the serial monitor and then using the myFile.println() function we will print the text “Testing text 1, 2 ,3…” into the file. After that we need to use close() function to ensure that the previous data written to the file is physically saved to the SD Card.
Next, we will see how we can read from the file. So again we will the same function, SD.open(), but this time as the file “test.txt” has already been created, the function will just open the file. Then using the myFile.read() function we will read from the file and print it on the serial monitor. The read() function actually reads just one character at a time, so therefore we need to use the “while” loop and the function myFile.available() to read all characters or the whole previously written data. At the end we need to close the file.
As we can see, the SD card has been successfully initialized, the writing to it has been successful as well, and also reading the written data or the string “Testing text 1, 2 ,3…” has been successful read. If we open the SD card on our computer we can see the created “test.txt” file and the written text in it.
Now let’s make another more interesting example of data logging a temperature sensor. For that purpose we will use the DS3231 Real Time Clock module which has a built-in temperature sensor as well. You can find more details about how to connect and use this module in my previous tutorial.
Code Description:First we need to include the libraries needed for both modules, then create the two objects and in the setup section initialize them.
After uploading the code the Arduino will start storing the temperature values each 3 seconds.After a while we can open the SD card on our computer to see the results.
Anyway now I commented that line, beacuse I am not interested in speed right now. But now the problem seems to be the programation code. the error message is as follows: ( I am using Arduino 1.8.7)
C:\Users\ADMIRAL\Videos\arduino\Libraries\Adafruit_ILI9341_AS\examples\ILI9341_draw_bitmap_v2\ILI9341_draw_bitmap_v2.ino:101:37: warning: ISO C++ forbids converting a string constant to "char*" [-Wwrite-strings]
C:\Users\ADMIRAL\Videos\arduino\Libraries\Adafruit_ILI9341_AS\examples\ILI9341_draw_bitmap_v2\ILI9341_draw_bitmap_v2.ino:106:42: warning: ISO C++ forbids converting a string constant to "char*" [-Wwrite-strings]
C:\Users\ADMIRAL\Videos\arduino\Libraries\Adafruit_ILI9341_AS\examples\ILI9341_draw_bitmap_v2\ILI9341_draw_bitmap_v2.ino:118:39: warning: ISO C++ forbids converting a string constant to "char*" [-Wwrite-strings]
C:\Users\ADMIRAL\Videos\arduino\Libraries\Adafruit_ILI9341_AS\examples\ILI9341_draw_bitmap_v2\ILI9341_draw_bitmap_v2.ino:121:42: warning: ISO C++ forbids converting a string constant to "char*" [-Wwrite-strings]
C:\Users\ADMIRAL\Videos\arduino\Libraries\Adafruit_ILI9341_AS\examples\ILI9341_draw_bitmap_v2\ILI9341_draw_bitmap_v2.ino:151:40: warning: ISO C++ forbids converting a string constant to "char*" [-Wwrite-strings]
C:\Users\ADMIRAL\Videos\arduino\Libraries\Adafruit_ILI9341_AS\examples\ILI9341_draw_bitmap_v2\ILI9341_draw_bitmap_v2.ino:163:39: warning: ISO C++ forbids converting a string constant to "char*" [-Wwrite-strings]
C:\Users\ADMIRAL\Videos\arduino\Libraries\Adafruit_ILI9341_AS\examples\ILI9341_draw_bitmap_v2\ILI9341_draw_bitmap_v2.ino:176:37: warning: ISO C++ forbids converting a string constant to "char*" [-Wwrite-strings]
C:\Users\ADMIRAL\Videos\arduino\Libraries\Adafruit_ILI9341_AS\examples\ILI9341_draw_bitmap_v2\ILI9341_draw_bitmap_v2.ino:183:38: warning: ISO C++ forbids converting a string constant to "char*" [-Wwrite-strings]
C:\Users\ADMIRAL\Videos\arduino\Libraries\Adafruit_ILI9341_AS\examples\ILI9341_draw_bitmap_v2\ILI9341_draw_bitmap_v2.ino:188:38: warning: ISO C++ forbids converting a string constant to "char*" [-Wwrite-strings]
C:\Users\ADMIRAL\Videos\arduino\Libraries\Adafruit_ILI9341_AS\examples\ILI9341_draw_bitmap_v2\ILI9341_draw_bitmap_v2.ino:193:38: warning: ISO C++ forbids converting a string constant to "char*" [-Wwrite-strings]
C:\Users\ADMIRAL\Videos\arduino\Libraries\Adafruit_ILI9341_AS\examples\ILI9341_draw_bitmap_v2\ILI9341_draw_bitmap_v2.ino:198:38: warning: ISO C++ forbids converting a string constant to "char*" [-Wwrite-strings]
C:\Users\ADMIRAL\Videos\arduino\Libraries\Adafruit_ILI9341_AS\examples\ILI9341_draw_bitmap_v2\ILI9341_draw_bitmap_v2.ino:205:39: warning: ISO C++ forbids converting a string constant to "char*" [-Wwrite-strings]
C:\Users\ADMIRAL\Videos\arduino\Libraries\Adafruit_ILI9341_AS\examples\ILI9341_draw_bitmap_v2\ILI9341_draw_bitmap_v2.ino:210:39: warning: ISO C++ forbids converting a string constant to "char*" [-Wwrite-strings]
C:\Users\ADMIRAL\Videos\arduino\Libraries\Adafruit_ILI9341_AS\examples\ILI9341_draw_bitmap_v2\ILI9341_draw_bitmap_v2.ino:215:39: warning: ISO C++ forbids converting a string constant to "char*" [-Wwrite-strings]
C:\Users\ADMIRAL\Videos\arduino\Libraries\Adafruit_ILI9341_AS\examples\ILI9341_draw_bitmap_v2\ILI9341_draw_bitmap_v2.ino:220:39: warning: ISO C++ forbids converting a string constant to "char*" [-Wwrite-strings]
C:\Users\ADMIRAL\Videos\arduino\Libraries\Adafruit_ILI9341_AS\examples\ILI9341_draw_bitmap_v2\ILI9341_draw_bitmap_v2.ino: In function "void drawBMP(char*, int, int, boolean)":
C:\Users\ADMIRAL\Videos\arduino\Libraries\Adafruit_ILI9341_AS\examples\ILI9341_draw_bitmap_v2\ILI9341_draw_bitmap_v2.ino:267:40: warning: converting to non-pointer type "int" from NULL [-Wconversion-null]
C:\Users\ADMIRAL\Videos\arduino\Libraries\Adafruit_ILI9341_AS\examples\ILI9341_draw_bitmap_v2\ILI9341_draw_bitmap_v2.ino: In function "void drawRAW(char*, int16_t, int16_t, int16_t, int16_t)":
C:\Users\ADMIRAL\Videos\arduino\Libraries\Adafruit_ILI9341_AS\examples\ILI9341_draw_bitmap_v2\ILI9341_draw_bitmap_v2.ino:377:40: warning: converting to non-pointer type "int" from NULL [-Wconversion-null]
C:\Users\ADMIRAL\Videos\arduino\Libraries\Adafruit_ILI9341_AS\examples\ILI9341_draw_bitmap_v2/ILI9341_draw_bitmap_v2.ino:355: undefined reference to `FatFile::close()"
C:\Users\ADMIRAL\Videos\arduino\Libraries\Adafruit_ILI9341_AS\examples\ILI9341_draw_bitmap_v2/ILI9341_draw_bitmap_v2.ino:338: undefined reference to `FatFile::read(void*, unsigned int)"
There are many tutorials on Arduino shields for 2.4 inch TFT LCD displays. In this road test I apply different tutorials to check the performance and issues of this specific shield: AZ-Delivery 2.4 inch TFT LCD display with resistive 4-wire touchscreen and an integrated SD card reader.AZ-Delivery 2.4 inch TFT LCD display.
TFT LCD is a variant of a liquid-crystal display (LCD) that uses thin-film-transistor (TFT) technology. That improves image quality, better contrast and addressability.
Depends on the needs of your project. Arduino UNO processor frequency is low. With the Arduino UNO full-color TFT LCDs are suitable to display simple data and commands. The TFT controller used cannot switch internal display RAM, so you can"t use the double buffer technique for animations but still you can only re-draw small sections of screen.
Given the limitations of the Arduino UNO the bigger the display the worse the performance. The size of this display is adequate to meet that compromise between number of pixels, display area and capabilities of the Arduino UNO.
This module consumes most of the resources available in Arduino UNO. This is not a limitation of the module itself. In return, using a parallel interface allows you to quickly update the image. If you want to take advantage of all its functionality (LCD + touch screen + SD card), only pins 0 and 1 (RX and TX, respectively) and pin 19 (A5) remain unused. If the SD card is not used, pins 10, 11, 12 and 13 are additionally available. With a suitable layout, some SPI devices could be connected even if the SD card is used.
The module arrived well packed and in perfect condition. The board comes in a sealed antistatic bag, with protective foams to prevent the terminals from bending, and all this wrapped with a bubble bag and inside an individual cardboard box. The label on the antistatic bag indicates the controller is an ILI9341.
The PCB silkscreen indicates the main function of each pin, the labels are easy to read, although it does not show labels for the touch screen pins:Pin 9 - Touch X+ / LCD_D1
The SD card reader is very well located between the USB connector and the power connector, it does not touch either of them as it happens in other lcd tft shield modules and it is easily accessible to insert and remove the SD cards.
You can directly use the shield with any arduino uno. In this case we are using an Arduino UNO that exposes all the pins both on the header and on the board. In such a way that you do not need another shield to access the pins not used by the screen
ShieldCompatible with Arduino. 5V compatible, can be used with 3.3V or 5V logic. On-board 3.3 V (300mA LDO controller). The design is very well thought out and fits Arduino UNO perfectly.
2x74LVC245A Octal Bus Transceiver With 3-State outputs. This octal bus transceiver is designed for 1.65-V to 3.6-V VCC operation. The LVC245A is designed for asynchronous communication between data buses. The device transmits data from the A bus to the B bus or from the B bus to the A bus, depending on the logic level at the direction-control (DIR) input. The output-enable (OE) input can be used to disable the device so the buses effectively are isolated. Inputs can be driven from either 3.3-V or 5-V devices. This feature allows the use of this device as a translator in a mixed 3.3-V/5-V system environment. This chip solves the problem of how to interface 3.3V logic devices to a 5.0V logic chip such as the Arduino. Most 3.3V devices do not like being run with 5V signals and can be damaged or flaky. The 74LVC245 is designed so that even when it runs at 1.8V, it still happily accepts 5V signals in one pin and converts it to a lower logic level on the opposite pin. It has 8 pipes it can convert but it won"t work with bi-directional/pull-up based devices such as I2C or 1-Wire. It does work great for SPI, Serial, Parallel bus, and other logic interfaces.
If you want to take advantage of all its functionality (LCD + touch screen + SD card), only pins 0 and 1 (RX and TX, respectively) and pin 19 (A5) remain unused. If the SD card is not used, pins 10, 11, 12 and 13 are additionally available. With a suitable layout, some SPI devices could be connected even if the SD card is used.
The ILI9341 which can control each pixel with a small number of pins. The shield connects ILI9341"s data pins 0-7 to Arduino digital pins 2-8 (allowing parallel communication, not SPI). ILI"s RESET goes to pin to Arduino analog pin A4.CS (chip select) to A3. RS (CD command/data) to A2. WR and RD to A1 and A0.
Includes a resistive 4-wire touchscreen (touchpad). The touch screen is attached on the surface of the display. Touch screen needs two analog inputs and two digital outputs. It connects through 4 wires, which share arduino pins 8, 9, A2, A3 with the ILI9341 driver. So you can"t write to LCD display and read the touch screen in the same time. I. Driver chip is XPT2046.
The resistive touch screen does not appear to appreciably affect the optical characteristics. Works properly, It takes a little pressure with the stylus for it to respond like in old mobile phones. You notice how it sinks into the screen when you press with the stylus. The stylus that comes with the module makes it easy to use if your interface design uses small controls. Some touch screen libraries offer better accuracy by specifying the resistance of the touch screen in the X direction. Resistance can be easily measured with a multimeter by connecting the test leads to the LCD_D1 - X + and LCD_DS X- terminals. Touch is sensitive to pressure.
The SD card reader works well. Accessing the SD card with the functions available in the SD library included in the IDE version used does not present any problem. SD cards are recognized and can be written or deleted.
I"ve frequently had a project where I wanted to write data to an SD card, or read from an SD card, but didn"t have enough I/O lines available to wire up the SPI SD card interface, or else the SPI lines were already in use, or else the processor I was using didn"t have enough RAM to run the SD library.
The ideal solution seemed to be an SD module with an I2C interface, but despite much searching on the web I couldn"t find one, so I decided to build one myself.
I initially thought of basing the circuit on the ATtiny841, like my earlier I2C GPS Module, but I underestimated the amount of RAM needed by the SD library, and the ATtiny814 only provides 512 bytes. I therefore switched to the 1‑series ATtiny1614 which provides 2 Kbytes.
For the controller I used an ATtiny1614. The SD library uses a lot of RAM so you need about 830 bytes, and the ATtiny804 or ATtiny814 aren"t suitable as they only have 512 bytes. I also tried an ATtiny1604, but that didn"t work, presumably because the 1 Kbytes of RAM doesn"t leave enough room for the stack. I"m pretty sure an ATtiny1624 should work, but I haven"t tried it.
The SD card module includes a CD pin which is connected to GND when a card is not inserted. You could connect this to a spare I/O line defined with INPUT_PULLUP to allow you to detect when a card is present.
You can use the I2C SD-Card Module with the Arduino Wire library, but it works best with my TinyI2C library; see Tiny I2C Routines for all AVR Microcontrollers. I give some examples in the following sections. Using TinyI2C it took 15 seconds to save the raw image from a 240x240 TFT display, consisting of 115200 bytes, to an SD Card. Reading it back to the display took 10 seconds.
The following example writes the bytes 48 to 90 (ASCII characters "0" to "Z") to the file "A1". Arduino Wire uses a 32-byte buffer, so you have to divide up what you"re writing into sections of not more than 32 bytes:
The following example reads the 43 characters we wrote to the file in the previous example, and prints them out using Serial.print(). Again, Arduino Wire uses a 32-byte buffer so we have to divide up what we are reading into 32-byte sections:
In this project I"ve implemented the essential functionality to read and write files to an SD card, but you could extend it to support the other features of the Arduino SD library
This Arduino album project is simple as it uses mainly an Arduino Uno board and an Arduino touch LCD shield only. The photographs to be displayed are converted to 240×320-pixel size with 24-bit colour format in BMP (bitmap) files using Microsoft Paint (or similar) software and stored on a micro SD card that is normally used for cell phones.
The Arduino Uno is a widely used microcontroller board based on Atmega328P microprocessor that is used in Arduino family boards. It has 14 digital input/output pins of which six can be used as PWM outputs and six as analogue inputs, and a USB port with 16MHz quartz crystal.
The Arduino touch LCD shield works on ILI9341 chip and has a built-in microSD card. The shield’s LCD display is sufficiently big (6cm, diagonally), bright (with four white-LED backlight), and colourful (18-bit having 262144 different shades). It has good resolution of 240×320 pixels with individual pixel control, 8-bit digital interface, plus four control lines with reset pin. The SD card has four more control pins. All the pin connections are directly compatible with Arduino Uno board, which eliminates wiring and new PCB requirement. It uses 3.3V power supply and supports both 3.3V or 5V logic levels.
Here MAX_FILES is the maximum number of files to be stored in the SD card and to be displayed sequentially, and DISP_DELAY is the delay (or time gap) in milliseconds for displaying each photograph.
Now disconnect the SD card reader from the computer and take out the microSD from card reader. Insert the microSD into the microSD card slot in Arduino LCD shield, as shown in Fig. 2.
Properly position the Arduino LCD shield on the Arduino Uno board, matching the 5V, 3.3V, and GND pins. Connect a 9V DC power supply to the Arduino Uno board.
Once the root folder is read from the SD card, the list of files stored in the SD card will be displayed on the LCD screen. Thereafter the photographs will be displayed sequentially.
(Note. The original BMP file supports colours up to 24-bit resolution, whereas LCD shield supports colours up to 18-bit resolution. So, display output may have slight mismatch with colours of original BMP file.)