TransWikia.com

Can't blink a LED using SPI interface on Raspberry Pi v3

Raspberry Pi Asked by PotatoBox on February 10, 2021

As a part of my PoC project, I’m using single 5050 LED made by Adafruit. I wired it like this (LED – RPi):

  • DI (Data Input) – SPI0 MOSI
  • CI (Clock Input) – SPI0 SCLK
  • GND (Ground) – GND
  • VCC (5V) – 5V PWR

SPI is, as far as I’m concerned, is enabled – I’ve done it using raspi-config and also added required line in /boot/config.txt manually (I’m talking bout param=spi=on)

Output of lsmod | grep spi* command:

spidev                 16384  0
spi_bcm2835            16384  0

And ls -la /dev/spi*:

crw-rw---- 1 root spi 153, 0 Jul 29 19:17 /dev/spidev0.0
crw-rw---- 1 root spi 153, 1 Jul 29 19:17 /dev/spidev0.1

To try out my setup, I’ve launched python interpreter and wrote:

import spidev
spi = spidev.SpiDev()
spi.open(0, 1)
resp = spi.xfer([0x00, 0x00, 0x00, 0x00])
resp = spi.xfer([0xFF, 0xFF, 0xFF, 0xFF])

And nothing happened. What’s important, I want to achieve my goal using Python. SpiDev module was installed at the time of the trials. For now, I’m only interested in simple blink, after this is reached, I can go further with modulation or frequency settings.

2 Answers

you are opened the wrong port.

spi.open(0,0) instead of spi.open(0,1) spi.open(0,1) means you are send data to SPI1 not SPI0.

Because you are send the data for wrong pin. That's why nothing happened.

Answered by Mike on February 10, 2021

At best you may "SEE" MOSI signal AKA "chip select" to change state when SPI device is "selected". You are "looking at " default speed of probably 100kHz which is hardly observable by human eye. You MAY be able to slow down the SPI data transfer by programming for minimal clock speed.

Answered by Jan Hus on February 10, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP