Flowing LEDs on a stairway ..better idea?

hippy

Technical Support
Staff member
There is something very odd going on if -

Code:
Symbol pause_word = W1
pause_word = 20000
pause pause_word
behaves any differently to "Pause 20000".

It might be an initialisation issue of some sort if you are downloading new programs into an already running PICAXE, or doing a power-cycle reset, ending up with an incomplete data transfer so the first clear in the new program is not initialising the LED strip as expected or something similar.
 

newplumber

Senior Member
Just to confuse you/me a little more
which i hope not to
but it seems to run backwards with two word variables in pause
code should be off 6 seconds...on a second
code does just the opposite ..on for 6 seconds ..off for a second

Code:
#picaxe 20x2
#no_table
#no_data

Symbol PAUSE_WORD = W1
Symbol PAUSE_WORD1 = W2
PAUSE_WORD = 6000 'OFF PAUSE
PAUSE_WORD1 = 1000 'ON PAUSE
; Set how many LED modules in the strip
symbol HOW_MANY_LEDS = 150

; Set the brightness of the LED while testing
; Use small values to keep current consumption low
symbol BRIGHTNESS    = 1 ; 0 to 255 (full)

; Initialise the HSPI interface
#macro init()
  hspisetup spimode00, spifast
#endmacro

; Send a four byte packet out via HSPI
#macro sendPacket( n1, n2, n3, n4 )
  hspiout( n1, n2, n3, n4 )
#endmacro

; Send the start of data header
#macro head()
  sendPacket( $00, $00, $00, $00 )
#endmacro

; Send a LED controlling command
#macro send( red, green, blue)
  sendPacket( $FF, blue, green, red )
#endmacro

; Send the end of data tail
#macro tail()
  sendPacket( $FF, $FF, $FF, $FF ) ; 1-64
  sendPacket( $FF, $FF, $FF, $FF ) ; 65-128
  sendPacket( $FF, $FF, $FF, $FF ) ; 129-192
#endmacro

; Turn a single LED off
#macro ledOff
  send( $00, $00, $00 )
#endmacro

; Turn a single LED on
#macro ledOn
  send(  $00, $00,BRIGHTNESS )
#endmacro

PowerOnReset:

  ; Initialise the HSPI interface
  init

  do
    gosub AllOff ; Turn all LEDs off
      pause PAUSE_WORD 'OFF PAUSE
    gosub AllOn  ; Turn all LEDs on
      pause PAUSE_WORD1 'ON PAUSE
  loop

AllOff:
  head
  for w0 = 1 to HOW_MANY_LEDS
    ledOff
  next
  tail
  return

AllOn:
  head
  for w0 = 1 to HOW_MANY_LEDS
    ledOn
  next
  tail
  return
even with a hard start ...(putting power to 20x2 right after hitting program button)
 

lbenson

Senior Member
Perhaps it is somewhere in the above posts, or elsewhere on the forum, but in general terms, how do head, tail, and send set up and control the addressing of the LEDs? (I understand the RGB (or BGR) aspect.)
 

newplumber

Senior Member
lbenson I checked the code 50 times to make sure the pause's are correct and somehow,somewhere,someway since i touched it lol
it broke...thats why i never never never look under my car hood :)
Okay when I first do a hard start program of this code
and right after it downloads
it seems to pause OFF for 6 seconds (which is right)
then pause ON for 6 seconds (which is wrong)
then pause OFF for a sec (which is wrong)
then pause ON for 6 seconds (which is wrong) ...etc i'm glad its a simple code and not 230 lines
 

hippy

Technical Support
Staff member
Perhaps it is somewhere in the above posts, or elsewhere on the forum, but in general terms, how do head, tail, and send set up and control the addressing of the LEDs? (I understand the RGB (or BGR) aspect.)
In terms of the general principle that's defined by the datasheet -

APA102 : https://cpldcpu.files.wordpress.com/2014/08/apa-102-super-led-specifications-2013-en.pdf
APA102C : https://cpldcpu.files.wordpress.com/2014/08/apa-102c-super-led-specifications-2014-en.pdf

And there's more detail and analysis on the internet, such as -

https://cpldcpu.com/2014/11/30/understanding-the-apa102-superled
 

lbenson

Senior Member
Thanks for the links, hippy. This is the summary from the last link:

In summary, each update of an APA102 based LED string should consist of the following:
1. A start frame of 32 zero bits (<0x00> <0x00> <0x00> <0x00>)
2. A 32 bit LED frame for each LED in the string (<0xE0+brightness> <blue> <green> <red>)
3. An end frame consisting of at least (n/2) bits of 1, where n is the number of LEDs in the string.

I understand that Mark is using white LEDs, so perhaps that explains the difference, but it appears to me that the position being used for BRIGHTNESS is actually the "blue" byte, and the actual brightness (if it is the first byte in the LED frame) is full--$FF (at least it seems to me that that would be the case for RGB LEDs).
 

newplumber

Senior Member
Yes hippy thanks for the links tho I understand so little
but lance I tried

Code:
#macro ledOn
  send( BRIGHTNESS, $00, $00)
#endmacro
Code:
#macro ledOn
  send(  $00,BRIGHTNESS , $00)
#endmacro
Code:
#macro ledOn
  send( $00, $00, BRIGHTNESS)
#endmacro
it all seems to work.....just backwards
but when I changed the pause around
like this\/ (note I changed the pause symbol to to make it more clear)
Symbol PAUSE_W_6000 = W1
Symbol PAUSE_W_1000 = W2
PAUSE_W_6000 = 6000
PAUSE_W_1000 = 1000
Code:
  do
    gosub AllOff ; Turn all LEDs off
      pause PAUSE_W_1000  'OFF PAUSE  ' stays off for 6 seconds 
    gosub AllOn  ; Turn all LEDs on
      pause PAUSE_W_6000 'ON PAUSE    ' stays on for 1 second 
  loop
Code:
  do
    gosub AllOff ; Turn all LEDs off
      pause PAUSE_W_6000  'OFF PAUSE  ' stays off for 1 seconds 
    gosub AllOn  ; Turn all LEDs on
      pause PAUSE_W_1000 'ON PAUSE    ' stays on for 6 seconds 
  loop
if this helps at all
I also recopied hippys code #76 and just changed the gosub AllOff pause
Code:
do
    gosub AllOff ; Turn all LEDs off
    pause 3000 '2000   so 2000 to 3000 and now I think its just flipping the gosubs and nothing wrong with the pauses
because it still stays on for 3 seconds and off for 2 seconds
 
Last edited:

hippy

Technical Support
Staff member
it all seems to work.....just backwards
Not sure how you mean by "backwards" or how which R, G or B you you set relates to what is set or using pauses.

One thing which always helps : Never describe something when two changes have been made ! Only change one thing at a time and describes what effect that has, or doesn't.


If, as it seems, you are saying the LEDs are on when off it might be something to do with the actual LEDs, not quite being the same as APA102(C) RGB. Do you have a link to the LED strips you are using ?
 

lbenson

Senior Member
As I see it, "send" accepts blue, green, and red values, and applies full brightness to whatever color is specified--$ff, of which %111xxxxx (and perhaps $1xxxxxxx) is the start of the LED frame, and %xxx11111 specifies full brightness. The only way to adjust brightness according to the link is to give the lower 5 bits of the first byte of the LED frame a value between 0 (which I suppose would be off), and 31 (which is the value the "send" macro provides).

If Mark's array works as the link shows with the APA102 controller, then there is no way with the macros provided to specify a variable brightness.

Since Mark's LEDs are white, in the absence of a datasheet, I'm not sure how he can determine what varying the blue, green, and red parameters do other than by experimentation.

None of this helps me to understand why he is seeing on as off and off as on.

Something to try: what happens with "send($fe,$fe,$fe)" (blue, green, red nearly full on) for the whole array?
 

newplumber

Senior Member
Okay sorry for having you hippy/lbenson deal with this little problem .....
I was hoping you wouldn't waste to much time on it ..you put to much time helping me already
I have it working fine with
Code:
do
    gosub AllOff ; Turn all LEDs off
    gosub AllOff ; Turn all LEDs off
    pause 5000
    gosub AllOn  ; Turn all LEDs on
    gosub AllOn  ; Turn all LEDs on
    pause 2000
  loop
It works perfectly so I think somehow it needs to read twice
and it stays off for the right pause time
and on for the right pause time
And big thank you for helping as much as you've done

opps lance I will try that didn't see it "Something to try: what happens with "send($fe,$fe,$fe)" (blue, green, red nearly full on) for the whole array?"

Okay I tried send "send($fe,$fe,$fe)" and does the same opposite ...on = off off = on and it sure is bright :) I see stars
thats with only using one gosub AllOff ..... and one gosub AllOn
 
Last edited:

lbenson

Senior Member
Here's something else to try:
Code:
#picaxe 20x2
#no_table
#no_data
symbol brightlevel = b4
symbol brightness = b5

hspisetup spimode00, spifast
for brightlevel = 1 to 31
  hspiout( $00, $00, $00, $00 ) ' start frame
  brightness = $E0+brightlevel 
  for w27 = 1 to 150
    hspiout( brightness, $FE, $FE, $FE ) ' turn on an LED (LED frame)
  next w27
  hspiout( $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF ) ' stop frame
  pause 2000
next brightlevel

'turn off
hspiout( $00, $00, $00, $00 ) ' start frame
for w27 = 1 to 150
    hspiout( $E0,0,0,0 ) ' turn off an LED (LED frame)
next w27
hspiout( $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF ) ' stop frame
Do all the leds light, and do they become continually brighter over the course of about a minute? Then do they all turn off?

If that works, can you time it to see how many seconds it takes from the time the first LED comes on until they turn off? Then maybe increase picaxe speed.
 
Last edited:

newplumber

Senior Member
thanks lance
Yes they do turn brighter
No they do not shut off
but the code works for the "for brightlevel = 1 to 31"
I will see if it will if I
make it turn off twice

if I add this then it turns off
Code:
'turn off
for b10 = 0 to 2
hspiout( $00, $00, $00, $00 ) ' start frame
for w27 = 1 to 150
    hspiout( $E0,0,0,0 ) ' turn off an LED (LED frame)
next w27
hspiout( $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF ) ' stop frame
next
 

lbenson

Senior Member
That it won't turn off with the original code is perplexing. I don't see how doing it three times makes a difference. But it is good that for this code, ON is ON and OFF is OFF (if repeated frequently enough).

You may be better off not using the macros until it is clear exactly what is happening.
 

lbenson

Senior Member
In the off section of code, try one of these. Maybe not enough length to the stop frame.

hspiout( $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF ) ' stop frame (160 high bits)

The link said the number of stop frame bits was equal to the number of LEDs divided by 2, but perhaps it should be (at least) the number of LEDs.
 

newplumber

Senior Member
lol true and thanks for trying and I have my strip working more importantly I can change it to what I want it to be
so all is needed is a few more added things such as senor inputs and install and done
but with out help from all of you I would be nowhere
I am hoping in a week I can be D..O..N...E
have to work this weekend but might have next week off

I didn't see your last post I will try it

EDIT> I tried it without the for b10... and same does not shut off


this shuts it off too with just 2 loops
Code:
'turn off
for b10 = 0 to 1
hspiout( $00, $00, $00, $00 ) ' start frame
for w27 = 1 to 150
    hspiout( $E0,0,0,0 ) ' turn off an LED (LED frame)
next w27
hspiout( $FF, $FF, $FF, $FF ) ' stop frame
next
 
Last edited:

lbenson

Senior Member
2:18 Greenwich Mean Time now. Brits may be up watching election returns, but perhaps not attending to picaxe stuff, so maybe just us North Americans now.

If you're inclined, try this and tell me what happens:
Code:
#no_data
symbol LED_ON = $FF
symbol LED_OFF = $E0
symbol loopCounter1 = b4
symbol loopCounter2 = b5
symbol onoff        = b6

hspisetup spimode00, spifast
for loopCounter1 = 150 to 1 step -1
  hspiout( $00, $00, $00, $00 ) ' start frame
  for loopCounter2 = 1 to 150
    onoff = LED_OFF
    if loopCounter2 = loopCounter1 then
      onoff = LED_ON
    else
      onoff = LED_OFF
    endif
    hspiout( onoff, $FE, $FE, $FE ) ' turn on (or off) an LED (LED frame)
  next loopCounter2
  hspiout( $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF ) ' stop frame
  pause 500
next loopCounter1

'turn off
hspiout( $00, $00, $00, $00 ) ' start frame
for loopCounter1 = 1 to 150
    hspiout( LED_OFF,0,0,0 ) ' turn off an LED (LED frame)
next loopCounter1
hspiout( $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF ) ' stop frame
 

newplumber

Senior Member
LOL okay ..I'm always inclined to try...worst it can happen is it WORKS!
going to try it
Okay I tried it but no leds came on
yes i forget they got the election over there
 

lbenson

Senior Member
Ok, I'll think about it and maybe try again tomorrow. Signing off for the night now. Glad you've made progress. Nice piece of kit.
 

newplumber

Senior Member
okay thanks alot tho I would personally forget about it
and I am sure i can manage to make this project work awesome
even if I have to gosub off_leds twice
take care
 

hippy

Technical Support
Staff member
Okay sorry for having you hippy/lbenson deal with this little problem .....
I was hoping you wouldn't waste to much time on it ..you put to much time helping me already
For ourselves it's always good to get to the bottom of things because, if it's not working for one, it may not work for another.
 

lbenson

Senior Member
Mark--I wasn't able to determine what was wrong with the last program I posted. It was intended to turn on the last LED in the string with all others off, then the next to last with all others off, and so on.

I wonder if you might be able to try again. This version only writes to the first 16 LEDs. The 16th should go on for a second, then off and the 15th on, and so on. When completed in approximately 16 seconds, it sends "Done" to the PC with sertxd.
Code:
' 20ACA102 ' drives string of leds controlled by aca102 controller over spi
#picaxe 20x2
#no_table
#no_data
symbol cLED_ON      = $FF
symbol cLED_OFF     = $E0
symbol cN_LEDs      = 16 ' 150
symbol loopCounter1 = b4
symbol loopCounter2 = b5
symbol onoff        = b6
symbol pinNo        = b7

sertxd(#c.7," ",#c.0," ",#b.7," ",#b.0,cr,lf)
hspisetup spimode00, spifast
for loopCounter1 = cN_LEDs to 1 step -1
  hspiout( $00, $00, $00, $00 ) ' start frame
  for loopCounter2 = 1 to cN_LEDs
    pinNo = loopCounter2 - 1 & %00001111 ' cycle through pins 0-15
    if loopCounter2 = loopCounter1 then
      onoff = cLED_ON
      if pinNo <> b.7 and pinNo <> b.5 then ' omit hspiout clock & data pins
'        high pinNo
      endif
    else
      onoff = cLED_OFF
      if pinNo <> b.7 and pinNo <> b.5 then ' omit hspiout clock & data pins
'         low pinNo
      endif
    endif
    hspiout( onoff, $FE, $FE, $FE ) ' turn on (or off) an LED (LED frame)
  next loopCounter2
  hspiout( $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF ) ' stop frame
  pause 1000
next loopCounter1

'turn off
hspiout( $00, $00, $00, $00 ) ' start frame
for loopCounter1 = 1 to cN_LEDs
  hspiout( cLED_OFF,0,0,0 ) ' turn off an LED (LED frame)
next loopCounter1
hspiout( $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF ) ' stop frame
sertxd("Done",cr,lf)
If it works, can you time it to see how many seconds it actually takes? I tested this turning on the pins of the 20x2 (except for the hspi pins), and the logic of sequencing last to first appears to be correct.

Thanks,

Lance
 

newplumber

Senior Member
Okay Lance I timed it and from right when I add power to the picaxe 20X2 (to get a perfect timing) till the serial terminal say "done" is 17.57 seconds +/- .10
The 17th,18th,19th led stay on bright from start till I quit paying my power bill (in other words never shuts off)
The 16th stays on for about a second and goes off
then 15 for a sec then goes off then 14 etc all the way to the first led
when the first led lights up it stays on just like the 17,18,19th

@hippy I understand ...and I don't even want to know what problems you faced ...at least in plumbing it doesn't take a rocket scientist to figure where a pipe is leaking
so the trouble shooting for me is a piece of cake ...its trying to figure out if I want a shower or not on how to fix it .
Its kinda funny that its opposite here where to fix this is the piece of cake ...or not.

EDIT> I even setup another board with a different picaxe 20x2 and tried the last code with the same results

EDIT> would it make a difference if I changed

Code:
  hspiout( onoff, $Fe, $Fe, $Fe ) ' turn on (or off) an LED (LED frame)
to

Code:
  hspiout( onoff, $Fa, $Fa, $Fa ) ' turn on (or off) an LED (LED frame)
so I dont have to wear a welding helmet (joking of course)
 
Last edited:

lbenson

Senior Member
The 17th,18th,19th led stay on bright from start till I quit paying my power bill
Well, that's a clue, since they should never be turned on in the first place. My guess is that what I thought was the "stop frame" of 12 bytes of $FF is actually being interpreted as 3 LED frames of 4 bytes each, turning all on. If that's the case, what is the real stop frame? Maybe you just use another "start frame".

I think I understand why the first LED stays on (i.e., the code never turns it off).
Would you mind trying this?
Code:
' 20ACA102 ' drives string of leds controlled by aca102 controller over spi
#picaxe 20x2
#no_table
#no_data
symbol cLED_ON      = $FF
symbol cLED_OFF     = $E0
symbol cN_LEDs      = 16 ' 150
symbol loopCounter1 = b4
symbol loopCounter2 = b5
symbol onoff        = b6
symbol pinNo        = b7

sertxd(#c.7," ",#c.0," ",#b.7," ",#b.0,cr,lf)
hspisetup spimode00, spifast
for loopCounter1 = cN_LEDs to 1 step -1
  hspiout( $00, $00, $00, $00 ) ' start frame
  for loopCounter2 = 1 to cN_LEDs
    pinNo = loopCounter2 - 1 & %00001111 ' cycle through pins 0-15
    if loopCounter2 = loopCounter1 then
      onoff = cLED_ON
      if pinNo <> b.7 and pinNo <> b.5 then ' omit hspiout clock & data pins
'        high pinNo
      endif
    else
      onoff = cLED_OFF
      if pinNo <> b.7 and pinNo <> b.5 then ' omit hspiout clock & data pins
'         low pinNo
      endif
    endif
    hspiout( onoff, $FE, $FE, $FE ) ' turn on (or off) an LED (LED frame)
  next loopCounter2
'  hspiout( $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF ) ' stop frame
  pause 1000
next loopCounter1
hspiout( $00, $00, $00, $00 ) ' start frame
hspiout( cLED_OFF,0,0,0 ) ' turn off an LED (LED frame) (first LED))
sertxd("Done",cr,lf)
(By the way, I've ordered my own RGB string, so I won't have to trouble you with this remote debugging.)

Lance
 

newplumber

Senior Member
WOW Lance you sure are gaining something
It Starts perfectly with only 16 on = sec ..no 17 no 18 no 19 no -----20-150
and works great all the way down till the first led and the first led still stays on
Oh it does not bother me one bit to keep testing/debugging
 

lbenson

Senior Member
... so I dont have to wear a welding helmet
Sure. $FE was just hanging from trying to check on brightness control. Are the LEDs lit with $01?

Is there a visible difference between hspiout( $F7, $7, $7, $7) and hspiout( $F7, $7, $0, $0)? (Since we're talking white LEDs)
 

newplumber

Senior Member
you mean hspiout( $FF, $7, $7, $7)
or try hspiout( $F7, $7, $7, $7)?

Yes I used this code hspiout( $F7, $7, $7, $7) and its alot dimmer
 

lbenson

Senior Member
Oh it does not bother me one bit to keep testing/debugging
OK, you asked for it. Try adding this before 'sertxd("Done",cr,lf)': hspiout( $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00 ) ' maybe a stop frame

IF that works, and you want to try the whole string, reduce the brightness, blue, green, red values to something you like (maybe $F7, $7, $0, $0), change the symbol definition of cN_LEDs from 16 to 150, change the pause value from 1000 to 250, and see if it walks down the whole chain of LEDs.
 

lbenson

Senior Member
I used this code hspiout( $F7, $7, $7, $7) and its alot dimmer
If you try hspiout( $F7, $7, 0, 0) is it dimmer still, or just the same (trying to determine if all three color values have effect with white LEDs, or just the first (blue)).
 

newplumber

Senior Member
Okay I will and it does shut it off but
like 3rd led on a sec
2nd led on a sec
1st led on for 1/8 second and then off

EDIT> Yes I tried hspiout( $F7, $7, 0, 0) and its dimmer still but
I used
symbol cLED_ON = $F7
and then
hspiout( onoff, $7,0,0 ) ' turn on (or off) an LED (LED frame)
and it run 150 to 1st led with 1st led on 1/8 sec all the rest around 1/4 with 250 pause

If I try using
hspiout( $F7, $7,0,0) ' turn on (or off) an LED (LED frame)
it lights up all the leds dimmly and stays on with none going off
 
Last edited:

lbenson

Senior Member
Okay I will and it does shut it off but
like 3rd led on a sec
2nd led on a sec
1st led on for 1/8 second and then off
Ok, right. Needs another "pause 1000" right after "next loopCounter1".

If you changed the other pause to 250, make the new one 250 also.
 

newplumber

Senior Member
Okay I added the pause right under "next loopCounter1" so

Code:
  next loopCounter2
'  hspiout( $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF ) ' stop frame
  pause 200
next loopCounter1
pause 200
and it still flickers I am guessing it faster then 1/8 maybe a 1/32 but i don't have a tape :)
 

lbenson

Senior Member
If I try using
hspiout( $F7, $7,0,0) ' turn on (or off) an LED (LED frame)
it lights up all the leds dimmly and stays on with none going off
Try: cLED_ON = $E1 ' $E1 is lowest brightness, $FF is highest

In the hspiout command, the first parameter ("brightness") has to be $E0 for off, and $E1 to $FF for increasing brightness (as in last night's code).

Looks like you've got lots to play with now. I'm retiring for the night to watch TV with the wife.
 

newplumber

Senior Member
Ya I would of retired long time ago lol
Yes I will keep trying and if you see smoke west of you in a distance don't worry about it
thanks again
 

newplumber

Senior Member
Okay here is the code that works PEEEERRRRFECTLY
@hippy you are right with your code in kicking the first ball harder or 3 more hspiout( $00, $00, $00,$00)... in "tail" if I make sense
@ Lbenson Lance I am so glad you put your time into this one (helping with $00)..I think we have it figured out now
atleast I am celebrating :) so this code thanks to Hippy (all I changed is "tail" $00 etc and added extra ;comments) doesn't do anything weird but work perfectly that i tested so far
and it does everything it's suppose to do.
Thanks alot for all the help now I can move on to the finnish line..prolly with a flat tire
Your happy friend Mark





Code:
#picaxe 20x2 ' 5 METER SINGLE LED APA102 WHITE CODE  30 leds per METER 
#no_table
#no_data

; Set how many LED modules in the strip
symbol HOW_MANY_LEDS = 5 ;<-- how many leds you want to blink on and off starting with 1st

; Set the brightness of the LED while testing
; Use small values to keep current consumption low
symbol BRIGHTNESS    = 1 ; 0 to 255 (full)

; Initialise the HSPI interface
#macro init()
  hspisetup spimode00, spifast
#endmacro

; Send a four byte packet out via HSPI
#macro sendPacket( n1, n2, n3, n4 )
  hspiout( n1, n2, n3, n4 )
#endmacro

; Send the start of data header
#macro head()
  sendPacket( $00 ,$00 ,$00 ,$00 )
#endmacro

; Send a LED controlling command
#macro send( red, white, blue)
  sendPacket( $FF, red, white, blue ) ' (cough) I'm american :)
#endmacro

; Send the end of data tail
#macro tail()
   sendPacket( $00 ,$00 ,$00 ,$00 )1-64
   sendPacket( $00 ,$00 ,$00 ,$00 )
   sendPacket( $00 ,$00 ,$00 ,$00 )
#endmacro

; Turn a single LED off
#macro ledOff
  send( $00, $00, $00 )
#endmacro

; Turn a single LED on
#macro ledOn
  send(  $00, $00,BRIGHTNESS )
#endmacro

PowerOnReset:

  ; Initialise the HSPI interface
  init
     head
  for w0 = 1 to 150 ' makes all leds off 
    ledOff
  next
  tail 
 DO
    gosub AllOff ; Turns "HOW_MANY_LEDS"  LEDs off
      pause 3000 'OFF PAUSE
    gosub AllOn  ; Turns "HOW_MANY_LEDS"  LEDs on
      pause 1000 'ON PAUSE
 LOOP

AllOff:
  head
  for w0 = 1 to HOW_MANY_LEDS
    ledOff
  next
  tail
  return

AllOn:
  head
  for w0 = 1 to HOW_MANY_LEDS
    ledOn
  next
  tail
  return
 
Last edited:

newplumber

Senior Member
Hi everyone

Here is the almost finished led stairs just need some touch ups/ tune ups but I was trying to use premelec's idea
of changing brightness as a person walks up/down the stairs using 8 motion sensors, after alot of hours of trying to make the sr-501 motion sensor
be my friend by having the sensor output turn on under .25 sec and output turn off less .5 second.. I just wasn't winning so I just used two ..one on the top and one at the bottom ...(maybe if/next stair project some pro here could make it work). I don't have to worry about my kids getting their exercise in ...maybe in a few weeks I wont have carpet anymore :) but again I am just happy it works as well as I hoped but thanks and with the great help from hippy, Lbenson, premelec,allycat, texasclodhopper,westaust55 and a few more I probably missed but without this forums I would be still lighting candles on each step for the same result and thank you again

https://www.youtube.com/watch?v=ba8HDeAKzJ0

btw...after making the trim for the stairs ..(wiping forehead)..i am glad i am plumber...(only took 2 full days)
maybe I should put the details in a finished project forum when I am done if one is interested
your friend mark
 

techElder

Well-known member
Mark, that is so cool! Fantastic job! Your self-deprecation is a joke, because you have arrived to the point of posting a finished project. Many will enjoy putting this into their homes. Me? I just sold the only home I ever had stairs in. :(
 

lbenson

Senior Member
Terrific, Mark. Very well done to get to this point from a standing start (so to speak) a few months ago.

Can you explain a little more about the sensors? Do you have 8 of them in place but not responding as you wish? Do the lights go down-to-up if your son starts at the top?

Once again, really nice work (and good work on the side trim on the stairs--as I suggested early on, that is a non-trivial retro-fitting job (me, I'm now fitting baseboard and doorway sills in a 170+ year old house after putting down new flooring--nothing is square, including the door jambs, cut through an original exterior wall when an addition was put on)).

Lance
 

newplumber

Senior Member
@ texasclod thankyou and I shouldn't need to much tylenol anymore.
I just sold the only home I ever had stairs in
you could do the same down a hallway...might have to go thicker trim to hide the leds
I am glad i have thin base trim...no changing to led strips till 2040

@ Lance thank you but its more thanks to you for helping a ton... the sensors?
I just have two installed one for the top and one for the bottom so it goes like this
Code:
DO
If bottom_sensor = 1 then flow_up_on 
If top_sensor    = 1 then flow_ down_on 
LOOP
BOTTOM_SENSOR:
' code here to flow leds up on 
If top_sensor = 1 then flow_up_off 'leds flows up off when top sensor = 1 meaning person is top of stairs 
TOP_SENSOR:
' code here to flow leds down on 
If bottom_sensor = 1 then flow_down_off 'leds flows down off when bottom sensor = 1 meaning person is bottom of stairs
Of course I have a lot more detail in the code such as wait time on in case your tired/slow and it takes 1+ minute to climb the stairs
but I still need it to be understandable/ readable before I post the main code ... but it does flow up or down with sensors fine.
170 year old houses seem not fun for me to touch ( trimming) it seems like making a curvy line look straight ...many trips to the saw
but good luck probably will turn out perfect
 
Top