Pages: [1] 2   Go Down
Author Topic: nano and SPI  (Read 891 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Full Member
***
Karma: 1
Posts: 152
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 452
Posts: 18694
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 443
Posts: 23834
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
#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);
  }
}
Logged

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.

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 452
Posts: 18694
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

It looks like it. Grrr.
Logged

Offline Offline
Full Member
***
Karma: 1
Posts: 152
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
« Last Edit: November 12, 2012, 03:28:11 am by robvoi » Logged

Offline Offline
Full Member
***
Karma: 1
Posts: 152
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 443
Posts: 23834
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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!
Logged

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.

Offline Offline
Full Member
***
Karma: 1
Posts: 152
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 452
Posts: 18694
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 452
Posts: 18694
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

Offline Offline
Full Member
***
Karma: 1
Posts: 152
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 452
Posts: 18694
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Offline Offline
Full Member
***
Karma: 1
Posts: 152
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Forum Administrator
Offline Offline
God Member
*****
Karma: 47
Posts: 629
I find plain exciting
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

@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
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 240
Posts: 24445
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I use it, it works.

Happy now?
Logged

"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.

Pages: [1] 2   Go Up
Jump to: