using nokia 5110 lcd screen and SD card reader/writer with SPI

hello... i'm very new to SPI and i'm not quite understanding how to connect my nokia screen and sd card reader to spi..

here's my understanding of SPI. i have MOSI and MISO pins, a serial clock pin.. and then the slave select. if i hook up my screen to the arduino directly, i can also hook up the SD card reader to the same pins and have a different slave select pin for that... thus saving some valuable pins in the process. it makes sence.. but i have no idea how to go about doing that.

for anyone that wishes to help... http://ladyada.net/products/nokia5110/ here's a tutorial for the nokia lcd screen that comes with example code.. and the sd chip library is in the arduino ide already.

can someone write a really basic bare bones code example of using these via SPI together. i honestly have no idea how to do it, but i really do need to save all the pins i can with my current project. (a wristwatch computer terminal) i can show anyone interested the code which includes the circuit and chips included written down. so far, it's an extremely affordable project.

but i thank you in advance, anyone who can give me any tips or example code.

There's nothing too magical other than knowing the various naming schemes of the SPI pins. Explaining the connections would be much simpler if you could provide a link to the exact SD card breakout.

It's important to distinguish between hardware SPI and software SPI. When you're using hardware SPI you're using pins 13, 12, 11, and 10 on the Arduino and the SPI library. If you're using software SPI you're usually using the ShiftOut and Shiftin functions and can use any pins; transfer rates will be much slower.

In general though, the clock (usually called CLK, CK, or SCK) pins are all connected together. The master's data in pin (MISO, master in slave out, hardware pin 12 on the Arduino) is connected to the data out pins (usually DO or SO) on each of the devices. The master's data out pin (MOSI, master out slave in, hardware pin 11) is connected to the data in pins (DI or SI) on the devices. Then as you mentioned each device gets a different connection for the chip select (CS or SS) from the Arduino (hardware pin 10).

The last thing to watch out for is level conversion. Assuming your Arduino is running at 5V you have to make sure that outgoing signals (the Clock, MOSI, and CS pins) are converted to 3.3V before it reaches any of the devices (SD cards and 5110 displays are both 3.3V devices). Incoming 3.3V signals (connected to the Arduino MISO pin) from the devices will still be treated as a digital high value by the 5V Arduino; they don't need to be translated up to 5V. Adafruit's tutorial with the 5110 explains how to do the 5V to 3.3V conversion with a 4050 IC.

http://www.gammon.com.au/spi

Chagrin: There's nothing too magical other than knowing the various naming schemes of the SPI pins. Explaining the connections would be much simpler if you could provide a link to the exact SD card breakout.

here is the SD card chip http://exrepicture.com/images/exre/BI/EXRE-BI00078.jpg

and http://4.bp.blogspot.com/-DoZixT7OLx0/Tgxvge6bEdI/AAAAAAAAAJA/6h61KvI3cOY/s1600/pinout_5110.jpg is the nokia 5110 lcd screen.

i don't know whether this would be software or hardware. but using the already defined hardware SPI pins look like it's easier and faster.

another thing is that the board i'm running is running off of USB right now as i test things. but the batteries i'm using for it power the device up with 3volts i'm building a wrist watch. and i don't want to suck power from the batteries too fast. so i'm making it use a low voltage to begin with. everything seems to be working fine that way for now

The SD card library is written to use hardware SPI. The Adafruit_PCD8544 library is written to use software SPI.

Is it possible to use both software and hardware SPI when connected to the hardware SPI pins? I've never tried myself.

interesting. i’ll have to do some more research. but thanks for telling me that. if i find anything, i’ll report it… but i don’t get the SD chip reader until monday. so it’s not like i can go ahead and wire it all up like that. or maybe…

i have this chip on the circuit as well. http://www.ebay.com/itm/321058651853?ssPageName=STRK:MEWAX:IT&_trksid=p3984.m1423.l2649

// Reset to pin 0
// Clock to pin 1
// Data to pin 3
// Busy to pin 4

it looks like the data pin could be the MOSI giving commands on what to do… and busy could be MISO to say it’s busy. clock is obviously SCLK… and reset would be off to the side and set to high unless we need it. would this be able to use hardware or software also? maybe instead of trying to combine hardware SPI and software SPI, and easier route to take is identify other things being used in the circuit to see if they fit either hardware or software SPI and then combining them with their pair. the goal here is to save as many pins i can so my device can have as much functionality as possible with one arduino. it doesn’t matter how i save pins… just… that i do save pins. is it possible to use this mp3 player chip in SPI? i honestly don’t know much about it. this is my first time dealing with it at all