Error message when using SPI

General project help for Adafruit customers

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
rshunter
 
Posts: 5
Joined: Wed Dec 26, 2012 5:07 pm

Error message when using SPI

Post by rshunter »

Using Arduino Uno, Dotstar.
I can use the dotstar strips fine using my own programming.
When I try to use hardware SPI. I get the following error message at compile time.

Code: Select all

            SPI_test.cpp.o: In function `WRITE_LED(unsigned char)':
            /usr/share/arduino/SPI_test.ino:44: undefined reference to `SPIClass::begin()'
            collect2: error: ld returned 1 exit status
I am just trying to light the first led in the string , blue.
Here is my code.

Code: Select all

/*    Test SPI CODE   */

#include "SPI.h"

const int dataReadyPin = 6;
const int chipSelectPin = 7;

  byte b0 =  B00000000;
  byte b255 = B11111111;

  byte GLOBOL = B1;
  byte RED    = B0;
  byte GREEN  = B0;
  byte BLUE   = B0;

void setup() {
  Serial.begin(57600);
  SPI.begin();
}

void loop() {
  GLOBOL = b0;
  BLUE   = b0;
  GREEN  = b0;
  RED    = b0;
  WRITE_LED(GLOBOL);  // send 32 bits of 0 to
  WRITE_LED(GLOBOL);  // start the led string
  WRITE_LED(GLOBOL);
  WRITE_LED(GLOBOL);
 delay (100);
  GLOBOL = b255;
  BLUE   = b255;       // turn on bright blue
  GREEN  = b0;
  RED    = b0;
  WRITE_LED(b255);     // send globol byte
  WRITE_LED(BLUE);     // send blue byte   
  WRITE_LED(GREEN);    // send green byte
  WRITE_LED(RED);      // send red byte
  delay (5000);  
}

void WRITE_LED(byte globol){
  SPI.transfer(globol);
}
Last edited by adafruit_support_rick on Thu Jan 29, 2015 11:35 am, edited 1 time in total.
Reason: please use Code tags when posting code (</> button)

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: Error message when using SPI

Post by adafruit_support_rick »

There is no SPI.begin function in the SPI library.
Also, there is a communication protocol for the DotStars - you can't simply write a byte of color to SPI and expect it to work.
Please have a look at the Adafruit DotStar library to see how it works.
https://github.com/adafruit/Adafruit_DotStar

Locked
Please be positive and constructive with your questions and comments.

Return to “General Project help”