Home
JAQForum Ver 20.06
Log In or Join  
Active Topics
Local Time 23:13 25 Apr 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : Picomite ws2812

Author Message
Zett

Newbie

Joined: 18/06/2022
Location: Netherlands
Posts: 14
Posted: 10:32am 09 Aug 2022
Copy link to clipboard 
Print this post

Hi ppl!,

I made some code to control a ws2812 leds(12ps)

Dim b%(11)=(0,0,0,0,0,0,0,0,0,0,0,0)
SetPin gp4,dout
Bitbang ws2812 o,gp4,12, b%()

Backlight 100
Colour &Hffffff,&H000000
CLS

groen=&h000000
rood=&H000000
For e=0 To 239
Line 10,e,70,e,1,e
groen=groen+&H000100
Line 80,e,140,e,1,groen
rood=rood+&h010000
Line 150,e,210,e,1,rood

Next e

Do


uitlezen:

x=Touch(x)
y=Touch(y)

If x<0 Or y<0 Then GoTo uitlezen
If y<15 Then y=0
If x>10 And x<70 Then ledblauw=y
If x>80 And x<140 Then ledgroen=y*&H010000
If x>150 And x<210 Then ledrood=y*&H000100

ledkleur=ledblauw+ledgroen+ledrood

Bitbang ws2812 o,gp4,1,ledkleur

Loop

But when i change that number in the last bitbang it will not work. is there a good way to use var. and adress all leds on there own?
 
disco4now

Guru

Joined: 18/12/2014
Location: Australia
Posts: 844
Posted: 10:47am 09 Aug 2022
Copy link to clipboard 
Print this post

If you have 12 leds, you must always send data for 12 leds.i.e.the whole array.
To change an individual led, just alter its colour in the array and leave the rest of the array unchanged.e.g.
DO
..
..
..
...

'Bitbang ws2812 o,gp4,1,ledkleur
b%(0)=ledkleur
Bitbang ws2812 o,gp4,12, b%()
LOOP
Edited 2022-08-09 20:48 by disco4now
Latest F4 Latest H7
 
Zett

Newbie

Joined: 18/06/2022
Location: Netherlands
Posts: 14
Posted: 11:08am 09 Aug 2022
Copy link to clipboard 
Print this post

offcourse. thx dude! i now got 12 leds i can adjust the color of. from a touch schreen written in basic! this is a happy day!

now i gona make a led clock with these ws2812!
Edited 2022-08-09 21:13 by Zett
 
lizby
Guru

Joined: 17/05/2016
Location: United States
Posts: 3013
Posted: 11:10am 09 Aug 2022
Copy link to clipboard 
Print this post

  Zett said  this is a happy day!

Post pics & code, please. We'll join in the celebration.
PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed
 
Zett

Newbie

Joined: 18/06/2022
Location: Netherlands
Posts: 14
Posted: 11:25am 09 Aug 2022
Copy link to clipboard 
Print this post

The code:

Dim b%(11)=(0,0,0,0,0,0,0,0,0,0,0,0)
SetPin gp4,dout
Bitbang ws2812 o,gp4,12, b%()
lednr=0
Backlight 100
Colour &Hffffff,&H000000
CLS

groen=&h000000
rood=&H000000
For e=0 To 239
Line 10,e,70,e,1,e
groen=groen+&H000100
Line 80,e,140,e,1,groen
rood=rood+&h010000
Line 150,e,210,e,1,rood

Next e

Do


uitlezen:

x=Touch(x)
y=Touch(y)

If x<0 Or y<0 Then GoTo uitlezen
If y<15 Then y=0
If x>10 And x<70 Then ledblauw=y
If x>80 And x<140 Then ledgroen=y*&H010000
If x>150 And x<210 Then ledrood=y*&H000100
If x>220 And x<319 Then GoTo volgende

ledkleur=ledblauw+ledgroen+ledrood

uit:

b%(lednr)=ledkleur

Bitbang ws2812 o,gp4,12, b%()

Pause 100

Loop

volgende:

lednr=lednr+1
If lednr>11 Then lednr=0
ledkleur=b%(lednr)
ledblauw=0:ledgroen=0:ledrood=0

GoTo uit

https://youtu.be/0nmR3HgxrPk
 
Martin H.

Guru

Joined: 04/06/2022
Location: Germany
Posts: 892
Posted: 11:43am 09 Aug 2022
Copy link to clipboard 
Print this post

Nice
'no comment
 
lizby
Guru

Joined: 17/05/2016
Location: United States
Posts: 3013
Posted: 11:48am 09 Aug 2022
Copy link to clipboard 
Print this post

Nice. Thanks for posting the video and code.

Can you provide a link for the ws2812 module?

Note that code is best posted here within the forum tags "[ CODE]" and "[ /CODE]" (without the spaces, which I put in so that the text would be shown, not acted upon by the forum). You can get these tags by pressing the [code] button above the message edit window. You can then insert your code between the two tags.

Dim b%(11)=(0,0,0,0,0,0,0,0,0,0,0,0)
SetPin gp4,dout
Bitbang ws2812 o,gp4,12, b%()
lednr=0
Backlight 100
Colour &Hffffff,&H000000
CLS

groen=&h000000
rood=&H000000
For e=0 To 239
Line 10,e,70,e,1,e
groen=groen+&H000100
Line 80,e,140,e,1,groen
rood=rood+&h010000
Line 150,e,210,e,1,rood

Next e

Do


uitlezen:

x=Touch(x)
y=Touch(y)

If x<0 Or y<0 Then GoTo uitlezen
If y<15 Then y=0
If x>10 And x<70 Then ledblauw=y
If x>80 And x<140 Then ledgroen=y*&H010000
If x>150 And x<210 Then ledrood=y*&H000100
If x>220 And x<319 Then GoTo volgende

ledkleur=ledblauw+ledgroen+ledrood

uit:

b%(lednr)=ledkleur

Bitbang ws2812 o,gp4,12, b%()

Pause 100

Loop

volgende:

lednr=lednr+1
If lednr>11 Then lednr=0
ledkleur=b%(lednr)
ledblauw=0:ledgroen=0:ledrood=0

GoTo uit

Using the code tags will also preserve any spacing you have--otherwise multiple spaces are stripped out.
PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed
 
Zett

Newbie

Joined: 18/06/2022
Location: Netherlands
Posts: 14
Posted: 12:04pm 09 Aug 2022
Copy link to clipboard 
Print this post

  lizby said  
Can you provide a link for the ws2812 module?


Nope. i bought it long ago its a cheap led thingy.
i wanted to learn python then. but im a basic guy. wanna code only basic :D
ha nice to know for the next code that code thing.
 
Zett

Newbie

Joined: 18/06/2022
Location: Netherlands
Posts: 14
Posted: 12:33pm 09 Aug 2022
Copy link to clipboard 
Print this post

now on to the time to var program. :)

got sec$=mid$(time$,7,2) and now make it in to 5 sec steps as a var%
 
Zett

Newbie

Joined: 18/06/2022
Location: Netherlands
Posts: 14
Posted: 07:11pm 09 Aug 2022
Copy link to clipboard 
Print this post


' clock

Dim b%(11)=(0,0,0,0,0,0,0,0,0,0,0,0)
SetPin gp4,dout
Bitbang ws2812 o,gp4,12, b%()

CLS
sec=0
min=1
uur=9


Do

wacht:
If Timer<5000 Then GoTo wacht

Timer =0

For e=0 To 11

 b%(e)=&H0

Next e


 sec=sec+1
  If sec>11 Then sec=0:minc=minc+1
  If minc=5 Then min=min+1
   If min>11 Then min=0:uur=uur+1
     If uur>11 Then uur=0



B%(sec)=&H010000
b%(min)=b%(min)+&H000100
b%(uur)=b%(uur)+&H000001

Bitbang ws2812 o,gp4,12, b%()



Loop



Clock on yt
Edited 2022-08-10 05:30 by Zett
 
Bill.b

Senior Member

Joined: 25/06/2011
Location: Australia
Posts: 225
Posted: 10:36pm 09 Aug 2022
Copy link to clipboard 
Print this post

This is code for a Christmas display using 120 LEDs

'Waterfall Star Christmas display - 6 strings of Ws2812 LEDs each string = 120 LEDs
'All LEDs strings clock connection connected to GP5
'Bill Brown   23/4/22.
' processor Raspberry pico and mmbasic.
 
 Option autorun on
 Option DEFAULT NONE

' Option EXPLICIT  
 Dim integer count, count1, rndnum, loopcnt, indexcount,count2, count3,cyclecount,i ' not all used in this version
 Dim integer buffer(200)
 '--------------------------------------------

 do
 for indexcount = 1 to 11
   For loopcnt = 0 To 179  'Read data for each pattern
     Read  buffer(loopcnt)
   Next loopcnt
 
  For count2 = 1 To 179       'rotate data in buffer array
    For loopcnt = 179 To 0 Step -1

       buffer(loopcnt + 1) = buffer(loopcnt)

    Next loopcnt
 
    buffer(0) = buffer(179) ' Move first LED to Last
       sendLED
    select case indexcount  'Set the delay for each pattern
     case 1
         pause 100
     case 2
       pause 50
     case 3
       pause 20
     case 4
        pause 100
     case 5
        pause 50
     case 6
        pause 100
     case 7
         pause 100
     case 8
         pause 100
     case 9
         pause 50
     case 10
         pause 50
     case 11
         pause 50
  end select
 Next count2
next indexcount
 Restore  
 loop

'-------------------------------------
sub sendLED

SetPin GP5, DOUT
Bitbang WS2812 B, GP5, 180, buffer()

end sub
'-------------------------------------
*********************************************************************
' Data for each pattern.  each data line is for 10 WS2812 LEDs
'  1  |R  G  B| R G  B |R  G  B| R  G  B| R  G  B| R  G  B|  R  G  B|  R  G  B| R  G  B| R G  B|  LED Number
 Data &h000000,&h300000,&h000000,&h003000,&h000000,&h000030,&h000000,&h301000,&h000000,&h300030'   1 to 10
 Data &h000000,&h300000,&h000000,&h003000,&h000000,&h000030,&h000000,&h301000,&h000000,&h300030  '11 to 20
 Data &h000000,&h300000,&h000000,&h003000,&h000000,&h000030,&h000000,&h301000,&h000000,&h300030'  21 to 30
 Data &h000000,&h300000,&h000000,&h003000,&h000000,&h000030,&h000000,&h301000,&h000000,&h300030 ' 31 to 40
 Data &h000000,&h300000,&h000000,&h003000,&h000000,&h000030,&h000000,&h301000,&h000000,&h300030'  41 to 50
 Data &h000000,&h300000,&h000000,&h003000,&h000000,&h000030,&h000000,&h301000,&h000000,&h300030 ' 51 to 60
 Data &h000000,&h300000,&h000000,&h003000,&h000000,&h000030,&h000000,&h301000,&h000000,&h300030'  61 to 70
 Data &h000000,&h300000,&h000000,&h003000,&h000000,&h000030,&h000000,&h301000,&h000000,&h300030 ' 71 to 80
 Data &h000000,&h300000,&h000000,&h003000,&h000000,&h000030,&h000000,&h301000,&h000000,&h300030'  81 to 90
 Data &h000000,&h300000,&h000000,&h003000,&h000000,&h000030,&h000000,&h301000,&h000000,&h300030 ' 91 to 100
 Data &h000000,&h300000,&h000000,&h003000,&h000000,&h000030,&h000000,&h301000,&h000000,&h300030' 101 to 110
 Data &h000000,&h300000,&h000000,&h003000,&h000000,&h000030,&h000000,&h301000,&h000000,&h300030 '111 to 120
 Data &h000000,&h300000,&h000000,&h003000,&h000000,&h000030,&h000000,&h301000,&h000000,&h300030' 121 to 130
 Data &h000000,&h300000,&h000000,&h003000,&h000000,&h000030,&h000000,&h301000,&h000000,&h300030 '131 to 140
 Data &h000000,&h300000,&h000000,&h003000,&h000000,&h000030,&h000000,&h301000,&h000000,&h300030' 141 to 150
 Data &h000000,&h300000,&h000000,&h003000,&h000000,&h000030,&h000000,&h301000,&h000000,&h300030 '151 to 160
 Data &h000000,&h300000,&h000000,&h003000,&h000000,&h000030,&h000000,&h301000,&h000000,&h300030' 161 to 170
 Data &h000000,&h300000,&h000000,&h003000,&h000000,&h000030,&h000000,&h301000,&h000000,&h300030 '171 to 180



'  3  |R  G  B| R G  B |R  G  B| R  G  B| R  G  B| R  G  B|  R  G  B|  R  G  B| R  G  B| R G  B|
 Data &h000030,&h000030,&h000030,&h000030,&h000030,&h000000,&h000000,&h000000,&h000000,&h000000'   1 to 10
 Data &h003000,&h003000,&h003000,&h003000,&h003000,&h000000,&h000000,&h000000,&h000000,&h000000  '11 to 20
 Data &h300000,&h300000,&h300000,&h300000,&h300000,&h000000,&h000000,&h000000,&h000000,&h000000'  21 to 30
 Data &h301000,&h301000,&h301000,&h301000,&h301000,&h000000,&h000000,&h000000,&h000000,&h000000 ' 31 to 40
 Data &h003030,&h003030,&h003030,&h003030,&h003030,&h000000,&h000000,&h000000,&h000000,&h000000'  41 to 50
 Data &h300030,&h300030,&h300030,&h300030,&h300030,&h000000,&h000000,&h000000,&h000000,&h000000 ' 51 to 60
 Data &h303000,&h303000,&h303000,&h303000,&h303000,&h000000,&h000000,&h000000,&h000000,&h000000'  61 to 70
 Data &h303030,&h303030,&h303030,&h303030,&h303030,&h000000,&h000000,&h000000,&h000000,&h000000 ' 71 to 80
 Data &h000030,&h000030,&h000030,&h000030,&h000030,&h000000,&h000000,&h000000,&h000000,&h000000'   1 to 10
 Data &h003000,&h003000,&h003000,&h003000,&h003000,&h000000,&h000000,&h000000,&h000000,&h000000  '11 to 20
 Data &h300000,&h300000,&h300000,&h300000,&h300000,&h000000,&h000000,&h000000,&h000000,&h000000'  21 to 30
 Data &h301000,&h301000,&h301000,&h301000,&h301000,&h000000,&h000000,&h000000,&h000000,&h000000 ' 31 to 40
 Data &h003030,&h003030,&h003030,&h003030,&h003030,&h000000,&h000000,&h000000,&h000000,&h000000'  41 to 50
 Data &h300030,&h300030,&h300030,&h300030,&h300030,&h000000,&h000000,&h000000,&h000000,&h000000 ' 51 to 60
 Data &h303000,&h303000,&h303000,&h303000,&h303000,&h000000,&h000000,&h000000,&h000000,&h000000'  61 to 70
 Data &h303030,&h303030,&h303030,&h303030,&h303030,&h000000,&h000000,&h000000,&h000000,&h000000 '151 to 160
 Data &h303000,&h303000,&h303000,&h303000,&h303000,&h000000,&h000000,&h000000,&h000000,&h000000'  61 to 70
 Data &h303030,&h303030,&h303030,&h303030,&h303030,&h000000,&h000000,&h000000,&h000000,&h000000'171 to 180

  ' fading colours
 '  4  |R  G  B| R G  B |R  G  B| R  G  B| R  G  B| R  G  B|  R  G  B|  R  G  B| R  G  B| R G  B|
 Data &h000040,&h000040,&h000040,&h000040,&h040040,&h080040,&h120040,&h140040,&h160040,&h200040  '
 Data &h250040,&h300040,&h350040,&h400040,&h400035,&h400030,&h400025,&h400020,&h400016,&h400012  '
 Data &h400008,&h400004,&h400000,&h400400,&h400800,&h401200,&h401400,&h401600,&h402000,&h402500 '
 Data &h403000,&h403500,&h404000,&h354000,&h304000,&h254000,&h204000,&h164000,&h124000,&h084000 '
 Data &h044000,&h004000,&h004005,&h004010,&h004014,&h004016,&h004020,&h004025,&h004030,&h004035  '
 Data &h004040,&h003540,&h003040,&h002540,&h002040,&h001640,&h001240,&h000840,&h000440,&h000040  '
 Data &h000040,&h000040,&h000040,&h000040,&h040040,&h080040,&h120040,&h140040,&h160040,&h200040  '
 Data &h250040,&h300040,&h350040,&h400040,&h400035,&h400030,&h400025,&h400020,&h400016,&h400012  '
 Data &h400008,&h400004,&h400000,&h400400,&h400800,&h401200,&h401400,&h401600,&h402000,&h402500 '
 Data &h403000,&h403500,&h404000,&h354000,&h304000,&h254000,&h204000,&h164000,&h124000,&h084000 '
 Data &h044000,&h004000,&h004005,&h004010,&h004014,&h004016,&h004020,&h004025,&h004030,&h004035  '
 Data &h004040,&h003540,&h003040,&h002540,&h002040,&h001640,&h001240,&h000840,&h000440,&h000040
 Data &h000040,&h000040,&h000040,&h000040,&h040040,&h080040,&h120040,&h140040,&h160040,&h200040  '
 Data &h250040,&h300040,&h350040,&h400040,&h400035,&h400030,&h400025,&h400020,&h400016,&h400012  '
 Data &h400008,&h400004,&h400000,&h400400,&h400800,&h401200,&h401400,&h401600,&h402000,&h402500 '
 Data &h403000,&h403500,&h404000,&h304000,&h304000,&h254000,&h204000,&h164000,&h124000,&h084000 '
 Data &h044000,&h004000,&h004005,&h004010,&h004014,&h004016,&h004020,&h004025,&h004030,&h004035  '
 Data &h004040,&h003540,&h003040,&h002540,&h002040,&h001640,&h001240,&h000840,&h000440,&h000040 '171 to 180
 '  red white and blue - Flag
 '  5  |R  G  B| R G  B |R  G  B| R  G  B| R  G  B| R  G  B|  R  G  B|  R  G  B| R  G  B| R G  B|
 Data &h000030,&h000030,&h000030,&h000030,&h000030,&h000030,&h000030,&h000030,&h000030,&h000030' 121 to 130
 Data &h000030,&h000030,&h000030,&h000030,&h000030,&h000030,&h000030,&h000030,&h000030,&h000030 '131 to 140
 Data &h000030,&h000030,&h000030,&h000030,&h000030,&h000030,&h000030,&h000030,&h000030,&h000030' 141 to 150
 Data &h000030,&h000030,&h000030,&h000030,&h000030,&h000030,&h000030,&h000030,&h000030,&h000030 '151 to 160
 Data &h000030,&h000030,&h000030,&h000030,&h000030,&h000030,&h000030,&h000030,&h000030,&h000030' 161 to 170
 Data &h000030,&h000030,&h000030,&h000030,&h000030,&h000030,&h000030,&h000030,&h000030,&h000030
 Data &h303030,&h303030,&h303030,&h303030,&h303030,&h303030,&h303030,&h303030,&h303030,&h303030'  61 to 70
 Data &h303030,&h303030,&h303030,&h303030,&h303030,&h303030,&h303030,&h303030,&h303030,&h303030 ' 71 to 80
 Data &h303030,&h303030,&h303030,&h303030,&h303030,&h303030,&h303030,&h303030,&h303030,&h303030'  81 to 90
 Data &h303030,&h303030,&h303030,&h303030,&h303030,&h303030,&h303030,&h303030,&h303030,&h303030 ' 91 to 100
 Data &h303030,&h303030,&h303030,&h303030,&h303030,&h303030,&h303030,&h303030,&h303030,&h303030' 101 to 110
 Data &h303030,&h303030,&h303030,&h303030,&h303030,&h303030,&h303030,&h303030,&h303030,&h303030 '111 to 120
 Data &h300000,&h300000,&h300000,&h300000,&h300000,&h300000,&h300000,&h300000,&h300000,&h300000'   1 to 10
 Data &h300000,&h300000,&h300000,&h300000,&h300000,&h300000,&h300000,&h300000,&h300000,&h300000  '11 to 20
 Data &h300000,&h300000,&h300000,&h300000,&h300000,&h300000,&h300000,&h300000,&h300000,&h300000'  21 to 30
 Data &h300000,&h300000,&h300000,&h300000,&h300000,&h300000,&h300000,&h300000,&h300000,&h300000 ' 31 to 40
 Data &h300000,&h300000,&h300000,&h300000,&h300000,&h300000,&h300000,&h300000,&h300000,&h300000'  41 to 50
 Data &h300000,&h300000,&h300000,&h300000,&h300000,&h300000,&h300000,&h300000,&h300000,&h300000   '171 to 180
'  White background
'  6  |R  G  B| R G  B |R  G  B| R  G  B| R  G  B| R  G  B|  R  G  B|  R  G  B| R  G  B| R G  B|
 Data &h010101,&h000031,&h010101,&h010101,&h010101,&h010101,&h010101,&h010101,&h003100,&h010101'   1 to 10
 Data &h010101,&h010101,&h010101,&h010101,&h310101,&h010101,&h010101,&h010101,&h010101,&h003131  '11 to 20
 Data &h010101,&h313131,&h010101,&h010101,&h010101,&h010101,&h010101,&h010101,&h010101,&h010101'  21 to 30
 Data &h010101,&h010101,&h010101,&h010101,&h010101,&h313100,&h010101,&h010101,&h010101,&h010101 ' 31 to 40
 Data &h010101,&h010101,&h010101,&h010101,&h010101,&h010101,&h010101,&h310100,&h010101,&h010101'  41 to 50
 Data &h010101,&h310031,&h010101,&h010101,&h010101,&h010101,&h010101,&h010101,&h010101,&h010101 ' 51 to 60
 Data &h010101,&h010101,&h010101,&h010101,&h010101,&h003100,&h010101,&h010101,&h010101,&h010101'  61 to 70
 Data &h010101,&h010101,&h010101,&h010101,&h010101,&h010101,&h010101,&h010101,&h000031,&h010101 ' 71 to 80
 Data &h010101,&h010101,&h010101,&h310030,&h010101,&h010101,&h010101,&h010101,&h010101,&h010101'  81 to 90
 Data &h010101,&h010101,&h010101,&h010101,&h010101,&h010101,&h010101,&h010101,&h010101,&h010101 ' 91 to 100
 Data &h010101,&h010101,&h010101,&h010101,&h310000,&h010101,&h010101,&h010101,&h010101,&h010101' 101 to 110
 Data &h010101,&h010101,&h010101,&h010101,&h010101,&h010101,&h010101,&h003131,&h010101,&h010101 '111 to 120
 Data &h010101,&h010101,&h010101,&h010101,&h301000,&h010101,&h010101,&h010101,&h010101,&h010101' 121 to 130
 Data &h010101,&h010101,&h010101,&h010101,&h010101,&h010101,&h003101,&h010101,&h010101,&h010101 '131 to 140
 Data &h010101,&h010101,&h010101,&h313131,&h010101,&h010101,&h010101,&h010101,&h010101,&h010101' 141 to 150
 Data &h010101,&h010101,&h010101,&h010101,&h010101,&h003100,&h010101,&h010101,&h010101,&h010101 '151 to 160
 Data &h010101,&h010101,&h010101,&h310000,&h010101,&h010101,&h010101,&h010101,&h010101,&h010101' 161 to 170
 Data &h010101,&h010101,&h010101,&h010101,&h010101,&h010101,&h000031,&h010101,&h010101,&h010101 '171 to 180

'  7  |R  G  B| R G  B |R  G  B| R  G  B| R  G  B| R  G  B|  R  G  B|  R  G  B| R  G  B| R G  B|
 Data &h300000,&h300030,&h003000,&h003030,&h000030,&h303000,&h303030,&h301000,&h000000,&h000000'   1 to 10
 Data &h300000,&h300030,&h003000,&h003030,&h000030,&h303000,&h303030,&h301000,&h000000,&h000000  '11 to 20
 Data &h300000,&h300030,&h003000,&h003030,&h000030,&h303000,&h303030,&h301000,&h000000,&h000000'  21 to 30
 Data &h300000,&h300030,&h003000,&h003030,&h000030,&h303000,&h303030,&h301000,&h000000,&h000000 ' 31 to 40
 Data &h300000,&h300030,&h003000,&h003030,&h000030,&h303000,&h303030,&h301000,&h000000,&h000000'  41 to 50
 Data &h300000,&h300030,&h003000,&h003030,&h000030,&h303000,&h303030,&h301000,&h000000,&h000000 ' 51 to 60
 Data &h300000,&h300030,&h003000,&h003030,&h000030,&h303000,&h303030,&h301000,&h000000,&h000000'  61 to 70
 Data &h300000,&h300030,&h003000,&h003030,&h000030,&h303000,&h303030,&h301000,&h000000,&h000000 ' 71 to 80
 Data &h300000,&h300030,&h003000,&h003030,&h000030,&h303000,&h303030,&h301000,&h000000,&h000000'  81 to 90
 Data &h300000,&h300030,&h003000,&h003030,&h000030,&h303000,&h303030,&h301000,&h000000,&h000000 ' 91 to 100
 Data &h300000,&h300030,&h003000,&h003030,&h000030,&h303000,&h303030,&h301000,&h000000,&h000000' 101 to 110
 Data &h300000,&h300030,&h003000,&h003030,&h000030,&h303000,&h303030,&h301000,&h000000,&h000000 '111 to 120
 Data &h300000,&h300030,&h003000,&h003030,&h000030,&h303000,&h303030,&h301000,&h000000,&h000000' 121 to 130
 Data &h300000,&h300030,&h003000,&h003030,&h000030,&h303000,&h303030,&h301000,&h000000,&h000000 '131 to 140
 Data &h300000,&h300030,&h003000,&h003030,&h000030,&h303000,&h303030,&h301000,&h000000,&h000000' 141 to 150
 Data &h300000,&h300030,&h003000,&h003030,&h000030,&h303000,&h303030,&h301000,&h000000,&h000000 '151 to 160
 Data &h300000,&h300030,&h003000,&h003030,&h000030,&h303000,&h303030,&h301000,&h000000,&h000000' 161 to 170
 Data &h300000,&h300030,&h003000,&h003030,&h000030,&h303000,&h303030,&h301000,&h000000,&h000000 '171 to 180

'  8  |R  G  B| R G  B |R  G  B| R  G  B| R  G  B| R  G  B|  R  G  B|  R  G  B| R  G  B| R G  B|
 Data &h000000,&h000000,&h000000,&h010100,&h020200,&h050500,&h101000,&h151500,&h252500,&h404000' 141 to 150
 Data &h000000,&h000000,&h000000,&h000002,&h000002,&h000005,&h000010,&h000015,&h000025,&h000040 '151 to 160
 Data &h000000,&h000000,&h000000,&h000100,&h000200,&h000500,&h001000,&h001500,&h002500,&h004000' 161 to 170
 Data &h000000,&h000000,&h000000,&h010000,&h020000,&h050000,&h100000,&h150000,&h250000,&h400000 ' 31 to 40
 Data &h000000,&h000000,&h000000,&h010101,&h020202,&h050505,&h101010,&h151515,&h252525,&h404040 '111 to 120
 Data &h000000,&h000000,&h000000,&h000101,&h000202,&h000505,&h001010,&h001515,&h002525,&h004040' 121 to 130
 Data &h000000,&h000000,&h000000,&h010001,&h020002,&h050005,&h100010,&h150015,&h250025,&h400040 '131 to 140
 Data &h000000,&h000000,&h000000,&h010100,&h020200,&h050500,&h101000,&h151500,&h252500,&h404000' 141 to 150
 Data &h000000,&h000000,&h000000,&h000002,&h000002,&h000005,&h000010,&h000015,&h000025,&h000040 '151 to 160
 Data &h000000,&h000000,&h000000,&h000100,&h000200,&h000500,&h001000,&h001500,&h002500,&h004000' 161 to 170
 Data &h000000,&h000000,&h000000,&h010000,&h020000,&h050000,&h100000,&h150000,&h250000,&h400000' 101 to 110
 Data &h000000,&h000000,&h000000,&h010101,&h020202,&h050505,&h101010,&h151515,&h252525,&h404040 '111 to 120
 Data &h000000,&h000000,&h000000,&h000101,&h000202,&h000505,&h001010,&h001515,&h002525,&h004040' 121 to 130
 Data &h000000,&h000000,&h000000,&h010001,&h020002,&h050005,&h100010,&h150015,&h250025,&h400040 '131 to 140
 Data &h000000,&h000000,&h000000,&h010100,&h020200,&h050500,&h101000,&h151500,&h252500,&h404000' 141 to 150
 Data &h000000,&h000000,&h000000,&h000002,&h000002,&h000005,&h000010,&h000015,&h000025,&h000040 '151 to 160
 Data &h000000,&h000000,&h000000,&h000100,&h000200,&h000500,&h001000,&h001500,&h002500,&h004000' 161 to 170
 Data &h000000,&h000000,&h000000,&h010000,&h020000,&h050000,&h100000,&h150000,&h250000,&h400000 '171 to 180
 
'  9  |R  G  B| R G  B |R  G  B| R  G  B| R  G  B| R  G  B|  R  G  B|  R  G  B| R  G  B| R G  B|
 Data &h000030,&h000030,&h000000,&h000000,&h003000,&h003000,&h000000,&h000000,&h300000,&h300000'   1 to 10
 Data &h000000,&h000000,&h301000,&h301000,&h000000,&h000000,&h300030,&h300030,&h000000,&h000000  '11 to 20
 Data &h003030,&h003030,&h000000,&h000000,&h303000,&h303000,&h000000,&h000000,&h303030,&h303030'  21 to 30
 Data &h000030,&h000030,&h000000,&h000000,&h003000,&h003000,&h000000,&h000000,&h300000,&h300000'   1 to 10
 Data &h000000,&h000000,&h301000,&h301000,&h000000,&h000000,&h300030,&h300030,&h000000,&h000000  '11 to 20
 Data &h003030,&h003030,&h000000,&h000000,&h303000,&h303000,&h000000,&h000000,&h303030,&h303030 ' 51 to 60
 Data &h000030,&h000030,&h000000,&h000000,&h003000,&h003000,&h000000,&h000000,&h300000,&h300000'   1 to 10
 Data &h000000,&h000000,&h301000,&h301000,&h000000,&h000000,&h300030,&h300030,&h000000,&h000000  '11 to 20
 Data &h003030,&h003030,&h000000,&h000000,&h303000,&h303000,&h000000,&h000000,&h303030,&h303030'  81 to 90
 Data &h000030,&h000030,&h000000,&h000000,&h003000,&h003000,&h000000,&h000000,&h300000,&h300000'   1 to 10
 Data &h000000,&h000000,&h301000,&h301000,&h000000,&h000000,&h300030,&h300030,&h000000,&h000000  '11 to 20
 Data &h003030,&h003030,&h000000,&h000000,&h303000,&h303000,&h000000,&h000000,&h303030,&h303030 '111 to 120
 Data &h000030,&h000030,&h000000,&h000000,&h003000,&h003000,&h000000,&h000000,&h300000,&h300000'   1 to 10
 Data &h000000,&h000000,&h301000,&h301000,&h000000,&h000000,&h300030,&h300030,&h000000,&h000000  '11 to 20
 Data &h003030,&h003030,&h000000,&h000000,&h303000,&h303000,&h000000,&h000000,&h303030,&h303030' 141 to 150
 Data &h000030,&h000030,&h000000,&h000000,&h003000,&h003000,&h000000,&h000000,&h300000,&h300000'   1 to 10
 Data &h000000,&h000000,&h301000,&h301000,&h000000,&h000000,&h300030,&h300030,&h000000,&h000000  '11 to 20
 Data &h003030,&h003030,&h000000,&h000000,&h303000,&h303000,&h000000,&h000000,&h303030,&h303030'171 to 180

'10
 Data &h001030,&h001030,&h001030,&h001030,&h001030,&h001030,&h001030,&h001030,&h001030,&h001030 ' 91 to 100
 Data &h301000,&h301000,&h301000,&h301000,&h301000,&h301000,&h301000,&h301000,&h301000,&h301000' 101 to 110
 Data &h300030,&h300030,&h300030,&h300030,&h300030,&h300030,&h300030,&h300030,&h300030,&h300030 '111 to 120
 Data &h003030,&h003030,&h003030,&h003030,&h003030,&h003030,&h003030,&h003003,&h003030,&h003030' 121 to 130
 Data &h303000,&h303000,&h303000,&h303000,&h303000,&h303000,&h303000,&h303000,&h303000,&h303000 '131 to 140
 Data &h303030,&h303030,&h303030,&h303030,&h303030,&h303030,&h303030,&h303030,&h303030,&h303030' 141 to 150
 Data &h000030,&h000030,&h000030,&h000030,&h000030,&h000030,&h000030,&h000030,&h000030,&h000030 '151 to 160
 Data &h003000,&h003000,&h003000,&h003000,&h003000,&h003000,&h003000,&h003000,&h003000,&h003000' 161 to 170
 Data &h300000,&h300000,&h300000,&h300000,&h300000,&h300000,&h300000,&h300000,&h300000,&h300000'  81 to 90
 Data &h001030,&h001030,&h001030,&h001030,&h001030,&h001030,&h001030,&h001030,&h001030,&h001030 ' 91 to 100
 Data &h301000,&h301000,&h301000,&h301000,&h301000,&h301000,&h301000,&h301000,&h301000,&h301000' 101 to 110
 Data &h300030,&h300030,&h300030,&h300030,&h300030,&h300030,&h300030,&h300030,&h300030,&h300030 '111 to 120
 Data &h003030,&h003030,&h003030,&h003030,&h003030,&h003030,&h003030,&h003003,&h003030,&h003030' 121 to 130
 Data &h303000,&h303000,&h303000,&h303000,&h303000,&h303000,&h303000,&h303000,&h303000,&h303000 '131 to 140
 Data &h303030,&h303030,&h303030,&h303030,&h303030,&h303030,&h303030,&h303030,&h303030,&h303030' 141 to 150
 Data &h000030,&h000030,&h000030,&h000030,&h000030,&h000030,&h000030,&h000030,&h000030,&h000030 '151 to 160
 Data &h003000,&h003000,&h003000,&h003000,&h003000,&h003000,&h003000,&h003000,&h003000,&h003000' 161 to 170
 Data &h300000,&h300000,&h300000,&h300000,&h300000,&h300000,&h300000,&h300000,&h300000,&h300000 '171 to 180
 
' 11  |R  G  B| R G  B |R  G  B| R  G  B| R  G  B| R  G  B|  R  G  B|  R  G  B| R  G  B| R G  B|
 Data &h000002,&h303030,&h000002,&h000002,&h000002,&h000002,&h000002,&h000002,&h000002,&h000002'   1 to 10
 data &h000002,&h000002,&h000002,&h000002,&h000002,&h303030,&h000002,&h000002,&h000002,&h000002  '11 to 20
 Data &h000002,&h000002,&h303030,&h000002,&h000002,&h000002,&h000002,&h000002,&h000002,&h000002'  21 to 30
 Data &h000002,&h000002,&h000002,&h000002,&h000002,&h000002,&h000002,&h000002,&h000002,&h000002'   1 to 10
 data &h000002,&h303030,&h000002,&h000002,&h000002,&h000002,&h303030,&h000002,&h000002,&h000002  '11 to 20
 Data &h000002,&h303030,&h000002,&h000002,&h303030,&h000002,&h000002,&h000002,&h000002,&h000002  '61 to 70
 Data &h000002,&h000002,&h303030,&h000002,&h000002,&h000002,&h000002,&h000002,&h000002,&h000002'   1 to 10
 data &h303030,&h000002,&h000002,&h000002,&h000002,&h000002,&h303030,&h000002,&h000002,&h000002  '11 to 20
 Data &h000002,&h000002,&h000002,&h000002,&h000002,&h000002,&h000002,&h000002,&h000002,&h000002 ' 91 to 100
 Data &h000002,&h000002,&h000002,&h000002,&h000002,&h303030,&h000002,&h000002,&h000002,&h000002'   1 to 10
 data &h000002,&h303030,&h000002,&h000002,&h000002,&h000002,&h000002,&h303030,&h000002,&h000002  '11 to 20
 Data &h000002,&h000002,&h303030,&h000002,&h000002,&h000002,&h000002,&h000002,&h000002,&h303030'   1 to 10
 data &h000002,&h000002,&h000002,&h000002,&h000002,&h303030,&h000002,&h000002,&h000002,&h000002  '11 to 20
 Data &h000002,&h000002,&h303030,&h000002,&h000002,&h000002,&h000002,&h000002,&h303030,&h000002 '151 to 160
 data &h000002,&h000002,&h000002,&h303030,&h000002,&h000002,&h000002,&h303030,&h000002,&h000002  '11 to 20
 Data &h000002,&h000002,&h000002,&h000002,&h303030,&h000002,&h000002,&h000002,&h303030,&h000002 '171 to 180
 Data &h000002,&h000002,&h303030,&h000002,&h000002,&h000002,&h000002,&h000002,&h000002,&h000002'   1 to 10
 data &h303030,&h000002,&h000002,&h000002,&h000002,&h000002,&h303030,&h000002,&h000002,&h000002
 
' 12  |R  G  B| R G  B |R  G  B| R  G  B| R  G  B| R  G  B|  R  G  B|  R  G  B| R  G  B| R G  B|
>
 Data &h000000,&h000000,&h000000,&h000040,&h040040,&h080040,&h120040,&h140040,&h160040,&h200040  '
 Data &h250040,&h300040,&h350040,&h400040,&h400035,&h400030,&h400025,&h400020,&h400016,&h400012  '
 Data &h400008,&h400004,&h400000,&h400400,&h400800,&h401200,&h401400,&h401600,&h402000,&h402500 '
 Data &h403000,&h403500,&h404000,&h354000,&h304000,&h254000,&h204000,&h164000,&h124000,&h084000 '
 Data &h044000,&h004000,&h004005,&h004010,&h004014,&h004016,&h004020,&h004025,&h004030,&h004035  '
 Data &h004040,&h003540,&h003040,&h002540,&h002040,&h001640,&h001240,&h000840,&h000440,&h000040  '
 Data &h000000,&h000000,&h000000,&h000040,&h040040,&h080040,&h120040,&h140040,&h160040,&h200040  '
 Data &h250040,&h300040,&h350040,&h400040,&h400035,&h400030,&h400025,&h400020,&h400016,&h400012  '
 Data &h400008,&h400004,&h400000,&h400400,&h400800,&h401200,&h401400,&h401600,&h402000,&h402500 '
 Data &h403000,&h403500,&h404000,&h354000,&h304000,&h254000,&h204000,&h164000,&h124000,&h084000 '
 Data &h044000,&h004000,&h004005,&h004010,&h004014,&h004016,&h004020,&h004025,&h004030,&h004035  '
 Data &h004040,&h003540,&h003040,&h002540,&h002040,&h001640,&h001240,&h000840,&h000440,&h000040
 Data &h000000,&h000000,&h000000,&h000040,&h040040,&h080040,&h120040,&h140040,&h160040,&h200040  '
 Data &h250040,&h300040,&h350040,&h400040,&h400035,&h400030,&h400025,&h400020,&h400016,&h400012  '
 Data &h400008,&h400004,&h400000,&h400400,&h400800,&h401200,&h401400,&h401600,&h402000,&h402500 '
 Data &h403000,&h403500,&h404000,&h304000,&h304000,&h254000,&h204000,&h164000,&h124000,&h084000 '
 Data &h044000,&h004000,&h004005,&h004010,&h004014,&h004016,&h004020,&h004025,&h004030,&h004035  '
 Data &h004040,&h003540,&h003040,&h002540,&h002040,&h001640,&h001240,&h000840,&h000440,&h000040

 ' 13  |R  G  B| R G  B |R  G  B| R  G  B| R  G  B| R  G  B|  R  G  B|  R  G  B| R  G  B| R G  B|
 Data &h000000,&h000000,&h000000,&h000000,&h000000,&h000000,&h000000,&h000000,&h000000,&h000000'   1 to 10
 Data &h000000,&h000000,&h000000,&h000000,&h000000,&h000000,&h000000,&h000000,&h000000,&h000000  '11 to 20
 Data &h000000,&h000000,&h000000,&h000000,&h000000,&h000000,&h000000,&h000000,&h000000,&h000000'  21 to 30
 Data &h000000,&h000000,&h000000,&h000000,&h000000,&h000000,&h000000,&h000000,&h000000,&h000000 ' 31 to 40
 Data &h000000,&h000000,&h000000,&h000000,&h000000,&h000000,&h000000,&h000000,&h000000,&h000000'  41 to 50
 Data &h000000,&h000000,&h000000,&h000000,&h000000,&h000000,&h000000,&h000000,&h000000,&h000000 ' 51 to 60
 Data &h000000,&h000000,&h000000,&h000000,&h000000,&h000000,&h000000,&h000000,&h000000,&h000000'  61 to 70
 Data &h000000,&h000000,&h000000,&h000000,&h000000,&h000000,&h000000,&h000000,&h000000,&h000000 ' 71 to 80
 Data &h000000,&h000000,&h000000,&h000000,&h000000,&h000000,&h000000,&h000000,&h000000,&h000000'  81 to 90
 Data &h000000,&h000000,&h000000,&h000000,&h000000,&h000000,&h000000,&h000000,&h000000,&h000000 ' 91 to 100
 Data &h000000,&h000000,&h000000,&h000000,&h000000,&h000000,&h000000,&h000000,&h000000,&h000000' 101 to 110
 Data &h000000,&h000000,&h000000,&h000000,&h000000,&h000000,&h000000,&h000000,&h000000,&h000000 '111 to 120
 Data &h000000,&h000000,&h000000,&h000000,&h000000,&h000000,&h000000,&h000000,&h000000,&h000000' 121 to 130
 Data &h000000,&h000000,&h000000,&h000000,&h000000,&h&h0000,&h000000,&h000000,&h000000,&h000000 '131 to 140
 Data &h000000,&h000000,&h000000,&h000000,&h000000,&h000000,&h000000,&h000000,&h000000,&h000000' 141 to 150
 Data &h000000,&h000000,&h000000,&h000000,&h000000,&h000000,&h000000,&h000000,&h000000,&h000000 '151 to 160
 Data &h000000,&h000000,&h000000,&h000000,&h000000,&h000000,&h000000,&h000000,&h000000,&h000000' 161 to 170
 Data &h000000,&h000000,&h000000,&h000000,&h000000,&h000000,&h000000,&h000000,&h000000,&h000000 '171 to 180
 

Bill
Edited 2022-08-10 08:38 by Bill.b
In the interests of the environment, this post has been constructed entirely from recycled electrons.
 
Zett

Newbie

Joined: 18/06/2022
Location: Netherlands
Posts: 14
Posted: 09:06am 10 Aug 2022
Copy link to clipboard 
Print this post

  Bill.b said  This is code for a Christmas display using 120 LEDs


Bill


Thx!! i can learn a lot from your code!!
 
Zett

Newbie

Joined: 18/06/2022
Location: Netherlands
Posts: 14
Posted: 08:57am 11 Aug 2022
Copy link to clipboard 
Print this post

Updated version.
now it got a next led button and it flashes the led that is selected.
and a CLR button. so you can set it to black again fast.


' ws2812 led circle 12
' Zett Darkstone 2022
'
'

Dim b%(11)=(0,0,0,0,0,0,0,0,0,0,0,0)
SetPin gp4,dout
Bitbang ws2812 o,gp4,12, b%()
lednr=0
Backlight 100
Colour &Hffffff,&H000000
CLS

groen=&h000000
rood=&H000000

For e=0 To 239
 Line 10,e,70,e,1,e
 groen=groen+&H000100
 Line 80,e,140,e,1,groen
 rood=rood+&h010000
 Line 150,e,210,e,1,rood
Next e

rc=&H606050

RBox 220,0,80,115,4,rc,rc
RBox 220,125,80,115,4,rc,rc
Box 10,0,61,240,4,rc
Box 80,0,61,240,4,rc
Box 150,0,61,240,4,rc


Text 259,54,"NEXT",cmv,4,1,0,rc
Text 259,179,"CLS",cmv,4,1,0,rc

Text 260,55,"NEXT",cmv,4,1,&Hffffff,-1
Text 260,180,"CLS",cmv,4,1,&Hffffff,-1


Do


uitlezen:

x=Touch(x)
y=Touch(y)

If x<0 Or y<0 Then GoTo uitlezen
If y<10 Then y=0
If x>10 And x<70 Then ledblauw=y
If x>80 And x<140 Then ledgroen=y*&H010000
If x>150 And x<210 Then ledrood=y*&H000100
If x>220 And x<319 And y<115 Then GoTo volgende
If x>220 And x<319 And y>125 Then b%(lednr)=&B000000

ledkleur=ledblauw+ledgroen+ledrood

uit:

b%(lednr)=ledkleur

Bitbang ws2812 o,gp4,12, b%()

Pause 40

Loop


volgende:

lednr=lednr+1
If lednr>11 Then lednr=0
ledkleur=b%(lednr)
B%(lednr)=&H111111
Bitbang ws2812 o,gp4,12,b%()
Pause 100
b%(lednr)=ledkleur

ledblauw=0:ledgroen=0:ledrood=0

GoTo uit






still got the idea to a save option and all leds same color
Edited 2022-08-11 19:12 by Zett
 
Zett

Newbie

Joined: 18/06/2022
Location: Netherlands
Posts: 14
Posted: 02:45pm 11 Aug 2022
Copy link to clipboard 
Print this post

other update with buttons:

-next
-cls
-all
-prev
-rnd

Option autorun on



' ws2812 led circle 12
' Zett Darkstone 2022
'
'

Dim b%(11)=(0,0,0,0,0,0,0,0,0,0,0,0)
SetPin gp4,dout
Bitbang ws2812 o,gp4,12, b%()
lednr=0
Backlight 100
Colour &Hffffff,&H000000
CLS

groen=&h000000
rood=&H000000

For e=0 To 239
 Line 10,e,70,e,1,e
 groen=groen+&H000100
 Line 80,e,140,e,1,groen
 rood=rood+&h010000
 Line 150,e,210,e,1,rood
Next e

rc=&H606050

RBox 220,0,80,40,4,rc,rc
RBox 220,50,80,40,4,rc,rc
RBox 220,100,80,40,4,rc,rc
RBox 220,150,80,40,4,rc,rc
RBox 220,200,80,40,4,rc,rc

Box 10,0,61,240,4,rc
Box 80,0,61,240,4,rc
Box 150,0,61,240,4,rc

Text 260,23,"NEXT",cm,4,1,&Hffffff,-1
Text 260,73,"CLS",cm,4,1,&Hffffff,-1
Text 260,123,"ALL",cm,4,1,&Hffffff,-1
Text 260,173,"PREV",cm,4,1,&Hffffff,-1
Text 260,223,"RND",cm,4,1,&Hffffff,-1

Do


uitlezen:

x=Touch(x)
y=Touch(y)

If x<0 Or y<0 Then GoTo uitlezen
If y<10 Then y=0
If x>10 And x<70 Then ledblauw=y
If x>80 And x<140 Then ledgroen=y*&H010000
If x>150 And x<210 Then ledrood=y*&H000100
If x>220 And x<319 And y<40 Then GoTo volgende
If x>220 And x<319 And y>50 And y<90 Then b%(lednr)=&B000000
If x>220 And x<319 And y>100 And y<140 Then GoTo alles
If x>220 And x<319 And y>150 And y<190 Then GoTo vorige
If x>220 And x<319 And y>200 And y<240 Then GoTo ran

ledkleur=ledblauw+ledgroen+ledrood

b%(lednr)=ledkleur

uit:


Bitbang ws2812 o,gp4,12, b%()

Pause 40

Loop


volgende:

lednr=lednr+1
If lednr>11 Then lednr=0
ledkleur=b%(lednr)
B%(lednr)=&H111111
Bitbang ws2812 o,gp4,12,b%()
Pause 100
b%(lednr)=ledkleur

ledblauw=0:ledgroen=0:ledrood=0

GoTo uit


vorige:

lednr=lednr-1
If lednr<0 Then lednr=11
ledkleur=b%(lednr)
B%(lednr)=&H111111
Bitbang ws2812 o,gp4,12,b%()
Pause 100
b%(lednr)=ledkleur

ledblauw=0:ledgroen=0:ledrood=0

GoTo uit

alles:

For e=0 To 11
b%(e)=ledkleur
Next e

GoTo uit

ran:
For e=0 To 11
b%(e)=Rnd(1)*&Hffffff
Next e

GoTo uit



Edited 2022-08-12 00:50 by Zett
 
Zett

Newbie

Joined: 18/06/2022
Location: Netherlands
Posts: 14
Posted: 02:57pm 16 Aug 2022
Copy link to clipboard 
Print this post

More for in a lamp.
Youtube vid

Option autorun on



' ws2812 led circle 12
' Zett Darkstone 2022
'
'
Dim b%(11)
SetPin gp4,dout
For e=0 To 11
b%(e)=&H303030
Bitbang ws2812 o,gp4,12, b%()
Pause 20
b%(e)=0
Bitbang ws2812 o,gp4,12, b%()
Pause 40
Next e

Backlight 100
Colour &Hffffff,&H000000
CLS

groen=&h000000
rood=&H000000

For e=0 To 239
 Line 10,e,70,e,1,e
 groen=groen+&H000100
 Line 80,e,140,e,1,groen
 rood=rood+&h010000
 Line 150,e,210,e,1,rood
Next e

rc=&H606050

RBox 220,0,80,40,4,rc,rc
RBox 220,50,80,40,4,rc,rc
RBox 220,100,80,40,4,rc,rc
RBox 220,150,80,40,4,rc,rc
RBox 220,200,80,40,4,rc,rc

Box 10,0,61,240,4,rc
Box 80,0,61,240,4,rc
Box 150,0,61,240,4,rc

Text 260,23,"ON",cm,4,1,&Hffffff,-1
Text 260,73,"FIRE",cm,4,1,&Hffffff,-1
Text 260,123,"MOVE",cm,4,1,&Hffffff,-1
Text 260,173,"FLAME",cm,4,1,&Hffffff,-1
Text 260,223,"RND",cm,4,1,&Hffffff,-1

ef=0

Do


uitlezen:

x=Touch(x)
y=Touch(y)

If x<0 Or y<0 Then GoTo ef
If y<10 Then y=0
If x>10 And x<70 Then ledblauw=y
If x>80 And x<140 Then ledgroen=y
If x>150 And x<210 Then ledrood=y

ledkleur=ledblauw+(ledgroen*&H010000)+(ledrood*&H000100)

If x>220 And x<319 And y<40 Then ef=0
If x>220 And x<319 And y>50 And y<90 Then ef=1
If x>220 And x<319 And y>100 And y<140 Then ef=2
If x>220 And x<319 And y>150 And y<190 Then ef=3
If x>220 And x<319 And y>200 And y<240 Then ef=4

ef:

If ef=0 GoTo ef0
If ef=1 GoTo ef1
If ef=2 GoTo ef2
If ef=3 GoTo ef3
If ef=4 GoTo ef4



uit:
Print ef
Bitbang ws2812 o,gp4,12, b%()

Pause 40

Loop


ef0:
For e=0 To 11
b%(e)=ledkleur
Next e
GoTo uit

ef1:

e=Rnd(1)*11
rl=Rnd(1)*&Hffffff And &H00ff00
If rl>&H00cc00 Then gl=Rnd(1)*&Hffffff And &H110000
b%(e)=rl+gl
Pause 40

GoTo uit

ef2:

e=e+1
If e>11 Then e=0
v=e-1: If v<0 Then v=11
b%(e)=ledkleur
b%(v)=0
Pause 40

GoTo uit

ef3:

e=Rnd(1)*11
b%(e)=Rnd(1)*&Hffffff And ledkleur
Pause 40

GoTo uit

ef4:

v=e:If v>11 Or v<0 Then v=0
e=Rnd(1)*11
b%(e)=ledkleur
B%(v)=&H0

GoTo uit

Edited 2022-08-17 00:59 by Zett
 
Print this page


To reply to this topic, you need to log in.

© JAQ Software 2024