Hello Guest it is March 29, 2024, 10:23:49 AM

Author Topic: Buttons to turn on LED's  (Read 6640 times)

0 Members and 1 Guest are viewing this topic.

Buttons to turn on LED's
« on: August 14, 2008, 11:31:52 PM »
I looked through most of the posts in this section and not sure were to start on this code:(

I want to have 6 buttons with Led's next to them when you push one button the led next to it lights up when you push another button the led next that button lights up and the previous one goes off. 
Any one see a sample VB code for this and were will the code need to go(macro pump)?  Does each button need its own code?

I made the buttons and leds, can I use any OemLed number over 1000 for the led?

Offline KTM

*
  •  92 92
    • View Profile
Re: Buttons to turn on LED's
« Reply #1 on: August 15, 2008, 02:16:32 AM »
Download the oem codes.xls link: http://www.machsupport.com/forum/index.php/topic,6657.0.html

In screen4 select "VB function edited in mach" for your buttons.
Save and close screen4, open mach - operator - edit button script - insert code.
eg:(toggle button)

If GetOEMLED (78) Then
   DeActivateSignal(Output5)
Else
   ActivateSignal(Output5)
End If

Regards

KTM

Re: Buttons to turn on LED's
« Reply #2 on: August 15, 2008, 09:08:58 PM »
Do you mean a mach screen LED or a physical LED in a panel? The above answer would handle physical LEDs that were connected to Output# signals.


If you mean screen LEDs. then each button needs to have code in it like this. Assume we are using LED1000, 1001, 1002 etc Each button looks the same, except it turns on its number and off all the others

 Call SetUserLED (1001,1)   'button 1 turn on led 1
  Call SetUserLED (1002,0)  'turn off all otehrs
  Call SetUserLED (1003,0)
  Call SetUserLED (1004,0)
  Call SetUserLED (1005,0)
  Call SetUserLED (1006,0)


Re: Buttons to turn on LED's
« Reply #3 on: August 16, 2008, 08:47:44 AM »
Ron,

Thank you much that is what I need!!

I looked through the wiki and didn't see that you need to put call before the SetUserLED.  So i was trying with out the call and nothing worked.

« Last Edit: August 16, 2008, 09:06:36 AM by DennisCNC »
Re: Buttons to turn on LED's
« Reply #4 on: October 07, 2020, 10:36:09 PM »
Is there A short code instead placing all user leds
like if user led 1300 is on then rest off ?

SetUserLED (1300, 1)
SetUserLED (1301, 0)
SetUserLED (1302, 0) 
SetUserLED (1303, 0)
SetUserLED (1304, 0)
SetUserLED (1305, 0)
SetUserLED (1306, 0) 
SetUserLED (1307, 0)
SetUserLED (1308, 0) 
SetUserLED (1309, 0)
SetUserLED (1310, 0) 
SetUserLED (1311, 0)
SetUserLED (1312, 0)
SetUserLED (1313, 0)
SetUserLED (1314, 0) 
SetUserLED (1315, 0)
SetUserLED (1316, 0)
SetUserLED (1317, 0)
SetUserLED (1318, 0) 
SetUserLED (1319, 0)
SetUserLED (1320, 0)
SetUserLED (1321, 0)
SetUserLED (1322, 0) 
SetUserLED (1323, 0)
SetUserLED (1324, 0) 
SetUserLED (1325, 0)
SetUserLED (1326, 0) 
SetUserLED (1327, 0)
SetUserLED (1328, 0)
SetUserLED (1329, 0)
SetUserLED (1330, 0) 
SetUserLED (1331, 0)
SetUserLED (1332, 0)
SetUserLED (1333, 0)
SetUserLED (1334, 0) 
SetUserLED (1335, 0)
SetUserLED (1336, 0)
SetUserLED (1337, 0)
SetUserLED (1338, 0) 
SetUserLED (1339, 0)
SetUserLED (1340, 0) 
SetUserLED (1341, 0)
SetUserLED (1342, 0) 
SetUserLED (1343, 0)
SetUserLED (1344, 0)
SetUserLED (1345, 0)
SetUserLED (1346, 0) 
SetUserLED (1347, 0)
SetUserLED (1348, 0)
SetUserLED (1349, 0)
SetUserLED (1350, 0) 
SetUserLED (1351, 0)
SetUserLED (1352, 0)
SetUserLED (1353, 0)
SetUserLED (1354, 0) 
SetUserLED (1355, 0)
SetUserLED (1356, 0) 
SetUserLED (1357, 0)
SetUserLED (1358, 0) 
SetUserLED (1359, 0)
SetUserLED (1360, 0)
SetUserLED (1361, 0)
SetUserLED (1362, 0) 
SetUserLED (1363, 0)
SetUserLED (1364, 0) 
SetUserLED (1365, 0)
SetUserLED (1366, 0) 
SetUserLED (1367, 0)
SetUserLED (1368, 0)
SetUserLED (1369, 0)
SetUserLED (1370, 0) 
SetUserLED (1371, 0)
SetUserLED (1372, 0) 
SetUserLED (1373, 0)
SetUserLED (1374, 0)
SetUserLED (1375, 0)
SetUserLED (1376, 0) 
SetUserLED (1377, 0)
SetUserLED (1378, 0) 
SetUserLED (1379, 0)
SetUserLED (1380, 0) 
SetUserLED (1381, 0)
SetUserLED (1382, 0) 
SetUserLED (1383, 0)
SetUserLED (1384, 0)
SetUserLED (1385, 0)
SetUserLED (1386, 0) 
SetUserLED (1387, 0)
SetUserLED (1388, 0) 
SetUserLED (1389, 0)
SetUserLED (1390, 0) 
SetUserLED (1391, 0)
SetUserLED (1392, 0) 
SetUserLED (1393, 0)
SetUserLED (1394, 0)
SetUserLED (1395, 0)
SetUserLED (1396, 0) 
SetUserLED (1397, 0)
SetUserLED (1398, 0) 
SetUserLED (1399, 0)
SetUserLED (1400, 0) 

Offline TPS

*
  •  2,501 2,501
    • View Profile
anything is possible, just try to do it.
if you find some mistakes, in my bad bavarian english,they are yours.
Re: Buttons to turn on LED's
« Reply #6 on: October 31, 2020, 11:11:31 AM »
WOW!! I knew it that was short code but I din't have The most minimum idea how to place it Thank you very much works great!!
Kind regards:
Victor
Re: Buttons to turn on LED's
« Reply #7 on: October 31, 2020, 05:35:47 PM »
Once again is there a short vbscript code for this? I'm trying to do a 100 buttons but if i go there is going to be a huge code And I bet there is a short code for this as well thank you for helping and  sorry for my dummy questions (

                PushButton 0,  0, 55, 55, "0", .but0
           PushButton 55,  0, 55, 55, "1", .but1
           PushButton 110,  0, 55, 55, "2", .but2
           PushButton 165,  0, 55, 55, "3", .but3
           PushButton 220,  0, 55, 55, "4", .but4
           PushButton 275,  0, 55, 55, "5", .but5
           PushButton 330,  0, 55, 55, "5", .but6
           PushButton 385,  0, 55, 55, "6", .but7
           PushButton 330,  0, 55, 55, "7", .but8
           PushButton 385,  0, 55, 55, "8", .but9

Offline TPS

*
  •  2,501 2,501
    • View Profile
Re: Buttons to turn on LED's
« Reply #8 on: November 01, 2020, 03:53:59 AM »
i am affraid there you have to go the "hard" road.
within a Dialog Definition is no For Next allowed, as fas i know.
anything is possible, just try to do it.
if you find some mistakes, in my bad bavarian english,they are yours.
Re: Buttons to turn on LED's
« Reply #9 on: November 01, 2020, 09:48:19 AM »
i finish the button but it looks to much code  >:D
For i = 1301 To 1401
SetUserLED (i, 0)
Next i

   
   Begin Dialog UserDialog1 0,0, 950, 520, "CNC NumPad:"  , .Enable
   
   
         CancelButton 902, 0, 45, 248
         PushButton 902,  250, 45, 248, "ZERO", .bttn0
        
        
                'ROW1 TO 10
               
           PushButton 0,  0, 90, 50, "1", .bttn1
           PushButton 90,  0, 90, 50, "2", .bttn2
                PushButton 180,  0, 90, 50, "3", .bttn3
             PushButton 270,  0, 90, 50, "4", .bttn4
                PushButton 360,  0, 90, 50, "5", .bttn5
           PushButton 450,  0, 90, 50, "6", .bttn6
                PushButton 540,  0, 90, 50, "7", .bttn7
                PushButton 630,  0, 90, 50, "8", .bttn8
                PushButton 720,  0, 90, 50, "9", .bttn9
                PushButton 810,  0, 90, 50, "10", .bttn10
   
               
               
               
               
                'ROW 11 TO 20
               
               
               
           PushButton 0,  50, 90, 50, "11", .bttn11
           PushButton 90,  50, 90, 50, "12", .bttn12
                PushButton 180,  50, 90, 50, "13", .bttn13
             PushButton 270,  50, 90, 50, "14", .bttn14
                PushButton 360,  50, 90, 50, "15", .bttn15
           PushButton 450,  50, 90, 50, "16", .bttn16
                PushButton 540,  50, 90, 50, "17", .bttn17
                PushButton 630,  50, 90, 50, "18", .bttn18
                PushButton 720,  50, 90, 50, "19", .bttn19
                PushButton 810,  50, 90, 50, "20", .bttn20
   
                           'ROW 21 TO 30



           PushButton 0, 100, 90, 50, "21", .bttn21
           PushButton 90,  100, 90, 50, "22", .bttn22
                PushButton 180, 100, 90, 50, "23", .bttn23
             PushButton 270, 100, 90, 50, "24", .bttn24
                PushButton 360, 100, 90, 50, "25", .bttn25
           PushButton 450, 100, 90, 50, "26", .bttn26
                PushButton 540, 100, 90, 50, "27", .bttn27
                PushButton 630, 100, 90, 50, "28", .bttn28
                PushButton 720, 100, 90, 50, "29", .bttn29
                PushButton 810, 100, 90, 50, "30", .bttn30
               
               
               
                 'ROW 31 TO 40

               
               
                PushButton 0, 150, 90, 50, "31", .bttn31
                PushButton 90,  150, 90, 50, "32", .bttn32
                PushButton 180,  150, 90, 50, "33", .bttn33
             PushButton 270,  150, 90, 50, "34", .bttn34
                PushButton 360,  150, 90, 50, "35", .bttn35
           PushButton 450,  150, 90, 50, "36", .bttn36
                PushButton 540,  150, 90, 50, "37", .bttn37
                PushButton 630,  150, 90, 50, "38", .bttn38
                PushButton 720,  150, 90, 50, "39", .bttn39
                PushButton 810,  150, 90, 50, "40", .bttn40
                           
                           
                           
                           
               'ROW 41 TO 50

               
                PushButton 0, 200, 90, 50, "41", .bttn41
                PushButton 90,  200, 90, 50, "42", .bttn42
                PushButton 180, 200, 90, 50, "43", .bttn43
             PushButton 270, 200, 90, 50, "44", .bttn44
                PushButton 360, 200, 90, 50, "45", .bttn45
           PushButton 450, 200, 90, 50, "46", .bttn46
                PushButton 540, 200, 90, 50, "47", .bttn47
                PushButton 630, 200, 90, 50, "48", .bttn48
                PushButton 720, 200, 90, 50, "49", .bttn49
                PushButton 810, 200, 90, 50, "50", .bttn50
 
 
 
 
                 'ROW 51 TO 60
                PushButton 0, 250, 90, 50, "51", .bttn51
                PushButton 90,  250, 90, 50, "52", .bttn52
                PushButton 180, 250, 90, 50, "53", .bttn53
             PushButton 270, 250, 90, 50, "54", .bttn54
                PushButton 360, 250, 90, 50, "55", .bttn55
           PushButton 450, 250, 90, 50, "56", .bttn56
                PushButton 540, 250, 90, 50, "57", .bttn57
                PushButton 630, 250, 90, 50, "58", .bttn58
                PushButton 720, 250, 90, 50, "59", .bttn59
                PushButton 810, 250, 90, 50, "60", .bttn60

                'ROW 61 TO 70
               
                PushButton 0, 300, 90, 50, "61", .bttn61
                PushButton 90,  300, 90, 50, "62", .bttn62
                PushButton 180, 300, 90, 50, "63", .bttn63
             PushButton 270, 300, 90, 50, "64", .bttn64
                PushButton 360, 300, 90, 50, "65", .bttn65
           PushButton 450, 300, 90, 50, "66", .bttn66
                PushButton 540, 300, 90, 50, "67", .bttn67
                PushButton 630, 300, 90, 50, "68", .bttn68
                PushButton 720, 300, 90, 50, "69", .bttn69
                PushButton 810, 300, 90, 50, "70", .bttn70
               
               
                 'ROW 71 TO 80
                PushButton 0, 350, 90, 50, "71", .bttn71
                PushButton 90,  350, 90, 50, "72", .bttn72
                PushButton 180, 350, 90, 50, "73", .bttn73
             PushButton 270, 350, 90, 50, "74", .bttn74
                PushButton 360, 350, 90, 50, "75", .bttn75
           PushButton 450, 350, 90, 50, "76", .bttn76
                PushButton 540, 350, 90, 50, "77", .bttn77
                PushButton 630, 350, 90, 50, "78", .bttn78
                PushButton 720, 350, 90, 50, "79", .bttn79
                PushButton 810, 350, 90, 50, "80", .bttn80
               
               
                 'ROW 81 TO 90

                PushButton 0, 400, 90, 50, "81", .bttn81
                PushButton 90,  400, 90, 50, "82", .bttn82
                PushButton 180, 400, 90, 50, "83", .bttn83
             PushButton 270, 400, 90, 50, "84", .bttn84
                PushButton 360, 400, 90, 50, "85", .bttn85
           PushButton 450, 400, 90, 50, "86", .bttn86
                PushButton 540, 400, 90, 50, "87", .bttn87
                PushButton 630, 400, 90, 50, "88", .bttn88
                PushButton 720, 400, 90, 50, "89", .bttn89
                PushButton 810, 400, 90, 50, "90", .bttn90
               
               
               
               
               
                 'ROW 91 TO 100

                PushButton 0, 450, 90, 50, "91", .bttn91
                PushButton 90,  450, 90, 50, "92", .bttn92
                PushButton 180, 450, 90, 50, "93", .bttn93
             PushButton 270, 450, 90, 50, "94", .bttn94
                PushButton 360, 450, 90, 50, "95", .bttn95
           PushButton 450, 450, 90, 50, "96", .bttn96
                PushButton 540, 450, 90, 50, "97", .bttn97
                PushButton 630, 450, 90, 50, "98", .bttn98
                PushButton 720, 450, 90, 50, "99", .bttn99
                PushButton 810, 450, 90, 50, "100", .bttn100
      
      
      

      



      

   End Dialog


   Dim Msg1 As UserDialog1


   x = Dialog( Msg1 )



Function Enable( ControlID$, Action%, SuppValue%)

   Select Case Action%
      Case 1
               
      

      Case 2 'Buttons sets
      

       
         If ControlID$ = "bttn0" Then
            Code "G0 X0000.0000"
             
         End If
         If ControlID$ = "bttn1" Then
            Code "G0 X0001.0000"

         
         End If
         If ControlID$ = "bttn2" Then
            Code "G0 X0002.0000"
      
         End If
         If ControlID$ = "bttn3" Then
            Code "G0 X0003.0000"

         End If
         If ControlID$ = "bttn4" Then
            Code "G0 X0004.0000"

         End If
         If ControlID$ = "bttn5" Then
            Code "G0 X0005.0000"

         End If
         If ControlID$ = "bttn6" Then
            Code "G0 X0006.0000"

         End If
         If ControlID$ = "bttn7" Then
            Code "G0 X0007.0000"

         End If
         If ControlID$ = "bttn8" Then
            Code "G0 X0008.0000"

         End If
         If ControlID$ = "bttn9" Then
            Code "G0 X0009.0000"

         End If
         If ControlID$ = "bttn10" Then
            Code "G0 X0010.0000"

      
         End If
         If ControlID$ = "bttn11" Then
            Code "G0 X0011.0000"

      
         End If
         If ControlID$ = "bttn12" Then
            Code "G0 X00012.0000"
         End If
         
         If ControlID$ = "bttn13" Then
            Code "G0 X0013.0000"

         End If
         If ControlID$ = "bttn14" Then
            Code "G0 X0014.0000"

         End If
         
         If ControlID$ = "bttn15" Then
            Code "G0 X0015.0000"

         End If
         If ControlID$ = "bttn16" Then
            Code "G0 X0016.0000"

         End If
         If ControlID$ = "bttn17" Then
            Code "G0 X0017.0000"
         End If
         
         If ControlID$ = "bttn0" Then
            Code "G0 X0000.0000"

         End If
         If ControlID$ = "bttn18" Then
            Code "G0 X0018.0000"

         End If
         
         If ControlID$ = "bttn19" Then
            Code "G0 X0019.0000"

         End If
         If ControlID$ = "bttn20" Then
            Code "G0 X0020.0000"

         End If
         
         
         
         If ControlID$ = "bttn21" Then
            Code "G0 X0021.0000"

         End If
         If ControlID$ = "bttn22" Then
            Code "G0 X0022.0000"

         End If
         
         If ControlID$ = "bttn23" Then
            Code "G0 X0023.0000"

         End If
         If ControlID$ = "bttn24" Then
            Code "G0 X0024.0000"

         End If
         If ControlID$ = "bttn25" Then
            Code "G0 X0025.0000"
         End If
         
         If ControlID$ = "bttn26" Then
            Code "G0 X0026.0000"

         End If
         If ControlID$ = "bttn27" Then
            Code "G0 X0027.0000"

         End If
         
         If ControlID$ = "bttn28" Then
            Code "G0 X0028.0000"

         End If
         If ControlID$ = "bttn29" Then
            Code "G0 X0029.0000"

         End If
         
      
         If ControlID$ = "bttn30" Then
            Code "G0 X0030.0000"

         End If
         
         If ControlID$ = "bttn31" Then
            Code "G0 X0031.0000"

         End If
         If ControlID$ = "bttn32" Then
            Code "G0 X0032.0000"

         End If
         
   
         If ControlID$ = "bttn33" Then
            Code "G0 X0033.0000"
         End If
         
         If ControlID$ = "bttn34" Then
            Code "G0 X0034.0000"

         End If
         If ControlID$ = "bttn35" Then
            Code "G0 X0035.0000"

         End If
         
         If ControlID$ = "bttn36" Then
            Code "G0 X0036.0000"

         End If
         If ControlID$ = "bttn37" Then
            Code "G0 X0037.0000"

         End If
         
         
         
         If ControlID$ = "bttn38" Then
            Code "G0 X0038.0000"

         End If
         If ControlID$ = "bttn39" Then
            Code "G0 X0039.0000"

         End If
         
         If ControlID$ = "bttn40" Then
            Code "G0 X0040.0000"

         End If
         If ControlID$ = "bttn41" Then
            Code "G0 X0041.0000"

         End If
   
         If ControlID$ = "bttn42" Then
            Code "G0 X0042.0000"
         End If
         
         If ControlID$ = "bttn43" Then
            Code "G0 X0043.0000"

         End If
         If ControlID$ = "bttn44" Then
            Code "G0 X0044.0000"

         End If
         
         If ControlID$ = "bttn45" Then
            Code "G0 X0045.0000"

         End If
         If ControlID$ = "bttn46" Then
            Code "G0 X0046.0000"


         End If
         If ControlID$ = "bttn47" Then
            Code "G0 X0047.0000"


         End If
         If ControlID$ = "bttn48" Then
            Code "G0 X0048.0000"

         End If
         If ControlID$ = "bttn49" Then
            Code "G0 X0049.0000"

         End If
         
         If ControlID$ = "bttn50" Then
            Code "G0 X0050.0000"

                        End If
         If ControlID$ = "bttn51" Then
            Code "G0 X0051.0000"
         End If
         If ControlID$ = "bttn52" Then
            Code "G0 X0052.0000"

         End If
         If ControlID$ = "bttn53" Then
            Code "G0 X0053.0000"

         End If
         If ControlID$ = "bttn54" Then
            Code "G0 X0054.0000"

         End If
         If ControlID$ = "bttn55" Then
            Code "G0 X0055.0000"

         End If
         If ControlID$ = "bttn56" Then
            Code "G0 X0056.0000"

         End If
         If ControlID$ = "bttn57" Then
            Code "G0 X0057.0000"

         End If
         If ControlID$ = "bttn58" Then
            Code "G0 X0058.0000"

         End If
         If ControlID$ = "bttn59" Then
            Code "G0 X0059.0000"
                        End If
         
                        If ControlID$ = "bttn60" Then
            Code "G0 X0060.0000"

         End If
         If ControlID$ = "bttn61" Then
            Code "G0 X0061.0000"

      
         End If
         If ControlID$ = "bttn62" Then
            Code "G0 X0062.0000"
         End If
         
         If ControlID$ = "bttn63" Then
            Code "G0 X0063.0000"

         End If
         If ControlID$ = "bttn64" Then
            Code "G0 X0064.0000"

         End If
         
         If ControlID$ = "bttn65" Then
            Code "G0 X0065.0000"

         End If
         If ControlID$ = "bttn66" Then
            Code "G0 X0066.0000"

         End If
         If ControlID$ = "bttn67" Then
            Code "G0 X0067.0000"
         End If
         
                        If ControlID$ = "bttn68" Then
            Code "G0 X0068.0000"

         End If
         
         If ControlID$ = "bttn69" Then
            Code "G0 X0069.0000"

         End If
         If ControlID$ = "bttn70" Then
            Code "G0 X0070.0000"

         End If
         
         If ControlID$ = "bttn71" Then
            Code "G0 X0071.0000"

         End If
         If ControlID$ = "bttn72" Then
            Code "G0 X0072.0000"

         End If
         
         If ControlID$ = "bttn73" Then
            Code "G0 X0073.0000"

         End If
         If ControlID$ = "bttn74" Then
            Code "G0 X0074.0000"

         End If
         If ControlID$ = "bttn75" Then
            Code "G0 X0075.0000"
         End If
         
         If ControlID$ = "bttn76" Then
            Code "G0 X0076.0000"

         End If
         If ControlID$ = "bttn77" Then
            Code "G0 X0077.0000"

         End If
         
         If ControlID$ = "bttn78" Then
            Code "G0 X0078.0000"

         End If
         If ControlID$ = "bttn79" Then
            Code "G0 X0079.0000"

         End If
         
      
         If ControlID$ = "bttn80" Then
            Code "G0 X0080.0000"

         End If
         
         If ControlID$ = "bttn81" Then
            Code "G0 X0081.0000"

         End If
         If ControlID$ = "bttn82" Then
            Code "G0 X0082.0000"

         End If
         
   
         If ControlID$ = "bttn83" Then
            Code "G0 X0083.0000"
         End If
         
         If ControlID$ = "bttn84" Then
            Code "G0 X0084.0000"

         End If
         If ControlID$ = "bttn85" Then
            Code "G0 X0085.0000"

         End If
         
         If ControlID$ = "bttn86" Then
            Code "G0 X0086.0000"

         End If
         If ControlID$ = "bttn87" Then
            Code "G0 X0087.0000"

         End If
         
         
         
         If ControlID$ = "bttn88" Then
            Code "G0 X0088.0000"

         End If
         If ControlID$ = "bttn89" Then
            Code "G0 X0089.0000"

         End If
         
         If ControlID$ = "bttn90" Then
            Code "G0 X0090.0000"

         End If
         If ControlID$ = "bttn91" Then
            Code "G0 X0091.0000"

         End If
   
         If ControlID$ = "bttn92" Then
            Code "G0 X0092.0000"
         End If
         
         If ControlID$ = "bttn93" Then
            Code "G0 X0043.0000"

         End If
         If ControlID$ = "bttn94" Then
            Code "G0 X0094.0000"

         End If
         
         If ControlID$ = "bttn95" Then
            Code "G0 X0095.0000"

         End If
         If ControlID$ = "bttn96" Then
            Code "G0 X0096.0000"


         End If
         If ControlID$ = "bttn97" Then
            Code "G0 X0097.0000"


         End If
         If ControlID$ = "bttn98" Then
            Code "G0 X0098.0000"

         End If
         If ControlID$ = "bttn99" Then
            Code "G0 X0099.0000"
            

         End If
         
         If ControlID$ = "bttn100" Then
         DoOEMButton(2)
            Code "G0 X0100.0000"

         End If
      
   End Select




End Function