[enter image description here][1]this is the code for my project to transmit a picture saved in directory by LED.
#!/usr/bin/python
from PIL import Image
import time
import spidev
import RPi.GPIO as GPIO
#set up SPI for LED
spi = spidev.SpiDev()
spi.open(0, 0)
spi.max_speed_hz = 31200000
buffer = bytearray() #put the bits in an array to rebuild
picture = bytearray() #this is where I store the final bits
file = open("logo.jpg", "rb")
bytes = bytearray(file.read())
for byte in bytes:
for i in range(8):
bit = (byte>>i) & 1
buffer.append(bit)
#send bits to the LED using SPI
if bit == 1:
resp = spi.xfer([0xFFFFFFF])
else:
resp = spi.xfer([0x00000000])
spi.close()
i m getting
resp=spi.xfer([0x00000000])
IOError [errno 9] bad file descriptor
Can someone please help me and tell where i m going wrong..i m new to coding. thank you for you time
User contributions licensed under CC BY-SA 3.0