Go Down

Topic: nano and SPI (Read 1 time) previous topic - next topic

robvoi

Hi,

short question: can I use SPI with the nano?

The arduino site states: SPI: 10 (SS), 11 (MOSI), 12 (MISO), 13 (SCK). These pins support SPI communication, which, although provided by the underlying hardware, is not currently included in the Arduino language.
In the forum though I find topics about the nano using SPI.

I want to use a nrf24L01 with it.


Thanks
Robert

Nick Gammon

It seems to have those pins:



Quote
The arduino site states: SPI: 10 (SS), 11 (MOSI), 12 (MISO), 13 (SCK). These pins support SPI communication, which, although provided by the underlying hardware, is not currently included in the Arduino language.


Where on earth does it say that? Certainly not here:

http://arduino.cc/en/Reference/SPI
http://www.gammon.com.au/electronics

CrossRoads

Yes you can. The SPI library uses those pins.
Here's a test sketch I was working on today.
D13, SCK, is connected to a shift register serial clock
D10, Latch, is connected to a shift register output register clock
D11, MOSI, is connected to a shift register Serial data in line.
When D5 is connected to GND, 11111111 is sent to the shift register.
When D5 is open (pulled high by internal pullup resistor) 00000000 is sent out.

Code: [Select]

#include <SPI.h>

byte latch = 10;

void setup(){

 pinMode (5, INPUT);
 digitalWrite(5, HIGH);

 pinMode (latch, OUTPUT);
 digitalWrite( latch, HIGH );
 SPI.begin();

}

void loop(){
 if (digitalRead(5) == LOW){

   digitalWrite(latch, LOW);
   SPI.transfer(0xFF);
   digitalWrite (latch, HIGH);
 }
 else {
   digitalWrite(latch, LOW);
   SPI.transfer(0x00);
   digitalWrite (latch, HIGH);
 }
}
Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Nick Gammon

Is this a cross-post of: http://arduino.cc/forum/index.php/topic,131566  ?

It looks like it. Grrr.
http://www.gammon.com.au/electronics

robvoi

#4
Nov 12, 2012, 09:24 am Last Edit: Nov 12, 2012, 09:28 am by robvoi Reason: 1

Is this a cross-post of: http://arduino.cc/forum/index.php/topic,131566  ?

It looks like it. Grrr.


No. It isn't. If you read the post carefully you see that in the post you state, I talk about my two Romeo All-in-One boards. Not about the nano.

So long.
Robert

robvoi


Quote
The arduino site states: SPI: 10 (SS), 11 (MOSI), 12 (MISO), 13 (SCK). These pins support SPI communication, which, although provided by the underlying hardware, is not currently included in the Arduino language.


Where on earth does it say that? Certainly not here:

http://arduino.cc/en/Reference/SPI


It's stated here: http://www.arduino.cc/en/Main/ArduinoBoardNano

At the link you posted, the nano isn't listed either.

Thanks
Robert

CrossRoads

Quote
SPI: 10 (SS), 11 (MOSI), 12 (MISO), 13 (SCK). These pins support SPI communication, which, although provided by the underlying hardware, is not currently included in the Arduino language.


Wow, is that page in need of an update!
Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

robvoi


Yes you can. The SPI library uses those pins.


Thanks a lot. It is really strange that it is nowhere stated that the nano works with SPI.
Even wikipedia doesn't state it: http://de.wikipedia.org/wiki/Arduino-Plattform

Thanks for the information.

Robert

Nick Gammon


At the link you posted, the nano isn't listed either.


What of it? As the Nano page says:

Quote
The Arduino Nano is a small, complete, and breadboard-friendly board based on the ATmega328  ...


The Atmega328 is the processor used in the Uno. The SPI library works on the Uno. Therefore it works on the Nano.

Quote
The arduino site states ...


It helps to quote the link in the original post, rather than having to have it dragged out of you. The site is quite large.
http://www.gammon.com.au/electronics

Nick Gammon


short question: can I use SPI with the nano?


See this page:

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

I took the first example, copied and pasted into a sketch, set the board type to Nano, and it compiled OK.

Was that too difficult for you to try for yourself?
http://www.gammon.com.au/electronics

robvoi

Hey Nick,
calm down. I don't own a nano but I am just evaluating which board to buy.
If you don't have something useful to state like "I use it, it works" or "tried it - doesn't work" please don't post.

Btw: That you can compile somehting doesn't mean it works.

Thanks
Robert

Nick Gammon

It's the same processor, it has the required pins, and the sketch compiles without errors. What more do you want? I don't have a nrf24L01 to hand to test it.
http://www.gammon.com.au/electronics

robvoi


It's the same processor, it has the required pins, and the sketch compiles without errors. What more do you want? I don't have a nrf24L01 to hand to test it.


Yep. That's why I wonder about the statement on arduino.cc and the listing of supported protocols on wikipedia.

Massimo Banzi

@robvoi

please be appreciative of the help you're getting. Nick is really helping you here.

BTW wikipedia is not a source of information about Arduino. There are several problems with their pages about Arduino but it's a pain to get them fixed.

m

AWOL

I use it, it works.

Happy now?
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Go Up