1

I recently purchased the TruOpto OST4ML5B32A RGB LED to use with the Raspberry Pi. I've viewed the datasheet https://www.rapidonline.com/pdf/72-9625.pdf for the LED and believe I need to send pulses to the DIn leg of the LED as is shown in 1. Data Format of the datasheet.

Data Sheet Information

I am now struggling to find out how to generate this square wave form from the rapsberry pi.

I believe that each 8 bits of information is sent within a 3ms time period. I get this from section 3. of the datasheet but I am not too sure on this.

Does anybody have any ideas on how to generate this waveform or has anybody used this LED before?

11
  • Is the LED controlled over I2C or simply via GPIO?
    – linusg
    Jan 25, 2017 at 14:12
  • @linusg I am not sure in all honesty. Some of my googling did lead me to articles about I2C but I wasn't sure how this worked. The LED only has one Din pin, VDD and GND pin and a Dout pin, so would I2C work in this setup?
    – Zach Dean
    Jan 25, 2017 at 15:02
  • Possibly. I2C has two wires + Vcc + GND, so depending on what Din and Dout (obviously data in and data out) are specifically for, it could be I2C. Normally this is stated in the data sheet, if you can find one.
    – linusg
    Jan 25, 2017 at 15:43
  • Sorry, just saw you,ve linked the data sheet. Honestly, it's not very useful at all. Can you link one or two of the articles you've found? All I get from Google are Chinese (Japanese?) and Russian shop pages :(
    – linusg
    Jan 25, 2017 at 15:51
  • I don't understand the waveform. It seems to have three values digital low, digital high, digital medium. What does that mean? Personally I'd google Arduino and the LED to see if anyone has interfaced to the device.
    – joan
    Jan 25, 2017 at 17:29

1 Answer 1

0

I do not know if the following will work but it is what I would try.

I'm going to assume DI is connected to GPIO4 (pin 7).

I would connect two 2k resistors to GPIO4. One between GPIO4 and ground, the other between GPIO4 and 3V3. This will form a resistor divider resulting in a voltage of about 1.7V on GPIO4 when it set to be an input. This forms the middle voltage (Z) of the needed signal. Setting GPIO4 as an output means that writing high or low will form the H or L voltage of the needed signal.

#!/usr/bin/env python

# OST4ML5B32A.py
# 2107-01-26
# Public Domain

import time
import pigpio

LED_GPIO=4 # Broadcom GPIO number

def send_bit(pi, GPIO, bit):
   #print(bit)
   pi.write(GPIO, bit)
   pi.set_mode(GPIO, pigpio.INPUT)

def send_byte(pi, GPIO, byte):
   #print("B", byte)
   for bit in range(8):
      send_bit(pi, GPIO, (byte>>(7-bit)) & 1)

def send_list(pi, GPIO, bytes):
   #print(bytes)
   for byte in bytes:
      send_byte(pi, GPIO, byte)

pi = pigpio.pi()
if not pi.connected:
   exit()

end_time = time.time()+60

B=0
G=0
R=0

while time.time() < end_time:

   send_list(pi, LED_GPIO, [B, G, R, B, G, R])

   B += 1
   if B > 255:
      B = 0
      G += 1
      if G > 255:
          G = 0
          R += 1
          if R > 255:
             R = 0

   time.sleep(0.003)

pi.stop()
1
  • @ZachDean That's good to know.
    – joan
    Feb 1, 2017 at 12:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.