Go Down

Topic: SPI different results on Yun and Uno boards (Read 435 times) previous topic - next topic


Hi all,

I'm trying to control three groups of LEDs through 74595s and SPI. I have things connected as you can see in the image below and the code produces a sequence where the LED light up from the center outward.

This works perfectly fine when I try it on my Uno, but on my Yun after a while (when Linux starts booting) the pattern breaks up and it looks like the wrong data gets sent to the LEDs.

I'm not sure why this happens. Can it be that there is other data being sent over SPI in between the time that I send my data and latch it? How can I fix this?

Code: [Select]
#include <SPI.h>

const int oe_pin = 8;

void setup() {               
  pinMode(oe_pin, OUTPUT);

int lights[27] = {0,4,0, 0,14,0, 2,10,8, 6,0,12, 12,0,6, 8,0,2, 0,0,0};
int l = 7;

void loop() {
  for (int i = 0; i < l; i ++) {
    digitalWrite(oe_pin, LOW);
    SPI.transfer(lights[i * 3]);
    SPI.transfer(lights[i * 3 + 1]);
    SPI.transfer(lights[i * 3 + 2]);
    digitalWrite(oe_pin, HIGH);

Go Up