Disco leds.

For issues with communication ports, protocols, etc.
Post Reply
TbbW
Posts: 348
Joined: Aug 19, 2005 10:08
Contact:

Disco leds.

Post by TbbW »

Yo!

Been working on getting some leds working with my computer in abit better fasion then just on or off that most ppl have seen tutorials on with the paralel port from the 90s.

I found on ebay these realy slick led strips from 30cm to 5meters in length so i wanted to put three 5 meter strips in my roof in the livingroom as mood light.
just look on ebay for: rgb led strip

This is just a little test with a rs232 led controller from Silicon Craft, it's just 20bucks + shipping so i desided "eh what the hell" and orderd it.
It's Common Anode so make sure yo buy led strips that are Common Anode.

First i just made blue and red react to the total volume from right and left channel via fmod from the mp3 player i made a long time ago.
Then with some help from attacke we did a proper spectrum to make
red=bass
green=middle registry
blue=discant ( kinda like a strob to high-hats)

And here is the code:

Code: Select all

' Fmod mp3 playback with spectrum
' Colors are sent thru com port
' and is made to work with SCColorMIX RGB LED Controller from silicon craft (www.siliconcraft.net)

' Lisence = Do what u want! ( but plz credit us :P )

' by TbbW and Attacke

'' Open the com port
Open Com "COM3:9600,N,8,1,CD0,CS0,DS0" As #1

#Include Once "fmod.bi"

Declare Sub set_color(ByVal col_r As UByte, ByVal col_g As UByte, ByVal col_b As UByte)
Declare Sub ErrorQuit( ByVal Message As String )
Declare Sub GetSpectrum()

Const FALSE = 0
Const TRUE = 1
Dim song As Integer Ptr
Dim As integer chan1,chan2,chan3
Dim Shared As Single Ptr SpectrumArray
SpectrumArray = Allocate(150*SizeOf(Single))

	'' Check DLL Version.
	If( FSOUND_GetVersion() < FMOD_VERSION ) Then
  		ErrorQuit( "FMOD version " & FMOD_VERSION & " or greater required" )
	End If
	'' Init Fmod
	If( FSOUND_Init(44100, 32, FSOUND_INIT_ACCURATEVULEVELS And FSOUND_INIT_GLOBALFOCUS And FSOUND_OUTPUT_DSOUND) = FALSE ) Then
  		ErrorQuit( "Can't initialize FMOD" )
	End If
	'' Load mp3 song.
	song =  FSOUND_Stream_Open("Mega_Man_2_Nuclear_Flash_OC_ReMix.mp3",FSOUND_STEREO,0,0)
	If ( song = 0 ) Then
	   ErrorQuit( "cant open song... sry!" )
	End If
	
''    ScreenRes 250,50,32,1,28
    ScreenRes 250,100,32,1 
    FSOUND_Stream_Play( 0 , song )
    FSOUND_DSP_SetActive(FSOUND_DSP_GetFFTUnit(), true)
    FSOUND_DSP_SetPriority(FSOUND_DSP_GetFFTUnit(), 150) 

Do
	'' Get the spectrum from fmod.
	GetSpectrum()

   ScreenLock
   Cls
   '' Red Spectrum
   For c As Integer = 0 To 29
   	Line (c,50)-(c,50-(SpectrumArray[c]*100)),RGB(255,0,0)
   	chan1 += (SpectrumArray[c]*255)
   Next
   '' Green Spectrum
   For c As Integer = 30 To 99
   	Line (c,50)-(c,50-(SpectrumArray[c]*100)),RGB(0,255,0)
   	chan2 += (SpectrumArray[c]*255)
   Next
   '' Blue Spectrum
   For c As Integer = 100 To 149
   	Line (c,50)-(c,50-(SpectrumArray[c]*100)),RGB(0,0,255)
   	chan3 += (SpectrumArray[c]*255)
   Next
   '' Blit color
	Line (0,50)-(250,100),Rgb((chan1/5),(chan2/5),(chan3/5)),bf
	'' Send color to com-port
	set_color((chan1/5),(chan2/5),(chan3/5))
	ScreenUnLock
	
	''set_color(chan1 * 100,chan2 * 100,chan3 * 100)
	chan1=0:chan2=0:chan3=0
Loop Until Inkey = Chr(27)

   '' Cleanup
   Deallocate(SpectrumArray)
   '' Fmod Cleanup.
   FSOUND_StopSound(0)
	FSOUND_Close
	'' Set the led's to off
	set_color(0,0,0)
	'' Close Com port.
	Close #1

Sub ErrorQuit( ByVal Message As String )

  Print "ERROR: "; Message
  FSOUND_Close
  End 1

End Sub

Sub set_color(ByVal col_r As UByte, ByVal col_g As UByte, ByVal col_b As UByte)
	'' Prefix to send instant color codes with this one is 0xFF and 0x01 followed by RRGGBB in total 5 bytes.
	Put #1,,Chr(255)+Chr(01)+Chr(col_r)+Chr(col_g)+Chr(col_b)
End Sub

sub GetSpectrum()
	Static As Single Ptr FSOUNDSpectrum
	If(FSOUNDSpectrum = 0) then
		FSOUNDSpectrum = FSOUND_DSP_GetSpectrum()
	End If
	Dim As integer ctr = 0
	Dim As Integer FreqPerBand = Fix(448 / 150)
    
    for i As Integer = 0 To 149
        SpectrumArray[i] = 0
        for j As Integer = 0 to FreqPerBand-1
            SpectrumArray[i] = FSOUNDSpectrum[i]
            ctr += 1
        Next
        SpectrumArray[i] /= FreqPerBand
    Next
End Sub
Song can be downloaded here: http://ocremix.org/remix/OCR01702/

I'm using a universial laptop charger at 15volts.
So i'm overloading the led strip by 3Volts since it's made for 12Volts but it's the only way to get enuff miliamps to power the 1meter led strip i'm using.

Some live action:
http://www.youtube.com/watch?v=JdLsSXRoHEc
j_milton
Posts: 458
Joined: Feb 11, 2010 17:35

Re: Disco leds.

Post by j_milton »

TbbW wrote:Yo!
I'm using a universial laptop charger at 15volts.
So i'm overloading the led strip by 3Volts since it's made for 12Volts but it's the only way to get enuff miliamps to power the 1meter led strip i'm using.
The forward voltage drop across a silicon diode is 0.7 volts, so if you hook 4 in series you can get a 2.8 volt drop and won't be overvolting your led's

Depending on how much current you might need to heat sink them to a piece of aluminum sheet or something...

Another option would be to use the base from one of those 12V halogen desk lamps, that will give you 50 watts ( aprox 4,000 milliamps), not sure how accurate the output voltage is but they are commonly available used or surplus and it would be a cheap experiment.
TbbW
Posts: 348
Joined: Aug 19, 2005 10:08
Contact:

Post by TbbW »

Seems the silicon diode is the best option doh :)

Since i'm going to hook this one up to a 12Volt signal repeater so i then can run the 15meter strip i got along the walls in the cealing :)
Post Reply