Hello Guest it is March 29, 2024, 07:13:56 AM

Author Topic: Tools led  (Read 1150 times)

0 Members and 1 Guest are viewing this topic.

Tools led
« on: February 24, 2018, 01:10:04 PM »
Hello,

can someone please help me with the code bellow. I have two led's on my screen named T01LED and T02LED and I want them to light up when tool number changes. I've put this code in PLC but it doesn't work. Thanks.

local inst = mc.mcGetInstance()
local currenttool = mc.mcToolGetCurrent(inst)

if (currenttool == "1") then
scr.SetProperty("T01LED", "Value", "1")
     else
         scr.SetProperty("T01LED", "Value", "0")
end
--------------------------
if (currenttool == "2") then
scr.SetProperty("T02LED", "Value", "1")
     else
         scr.SetProperty("T02LED", "Value", "0")
end


Regards,
Peter
Re: Tools led
« Reply #1 on: February 24, 2018, 02:05:47 PM »
You need to change 1 thing and it will work.

if (currenttool == 1) then         Don't put the numbers in  " ".   
if (currenttool == 2) then 

I put tested this code in the PLC script and it works just fine. =)

local inst = mc.mcGetInstance()
local currenttool = mc.mcToolGetCurrent(inst)

if (currenttool == 1) then
     scr.SetProperty("TestLED", "Value", "1")
else
     scr.SetProperty("TestLED", "Value", "0")
end
Chad Byrd
Re: Tools led
« Reply #2 on: February 24, 2018, 02:41:49 PM »
Thank you very much for that. I knew that was something simple. It work now thanks again.

Regards,
Peter