Created
April 26, 2021 02:27
-
-
Save futureshocked/44b4f06132c68cb8c1c7c26ea3ff42ca to your computer and use it in GitHub Desktop.
This script shows how to control an LabJack T4 COMM STATUS LED using Lua.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--[[ | |
LJ - 09.60 - blink_COMM_STATUS_LEDs.lua | |
This script shows how to control an LabJack T4 COMM STATUS LED using Lua. | |
Components | |
---------- | |
- LabJack T4 | |
Course | |
------ | |
Data acquisition and automation with LabJack | |
https://app.techexplorations.com/courses/labjack/ | |
--]] | |
--[[ | |
Name: blink_leds.lua | |
Desc: This example shows how to blink the status and COMM LEDs | |
Note: This example requires firmware 1.0282 (T7) or 1.0023 (T4) | |
--]] | |
print("Blink the COMM and Status LEDs at 1 Hz.") | |
-- Disable truncation warnings (truncation should not be a problem in this script) | |
MB.writeName("LUA_NO_WARN_TRUNCATION", 1) | |
local ledstatus = 0 | |
local i = 0 | |
local numiterations = 5 | |
-- Set the LED operation to manual (This allows users to control the status | |
-- and COMM LEDs) | |
MB.writeName("POWER_LED", 4) | |
-- Configure a 1000ms interval | |
LJ.IntervalConfig(0, 1000) | |
while i < numiterations do | |
-- If an interval is done | |
if LJ.CheckInterval(0) then | |
-- If the LEDs are on | |
if ledstatus == 1 then | |
-- Turn the LEDs off | |
ledstatus = 0 | |
print(ledstatus, "Off") | |
else | |
-- Turn the LEDs on | |
ledstatus = 1 | |
print(ledstatus, "On") | |
end | |
-- Apply the changes to the LEDs | |
MB.writeName("LED_COMM", ledstatus) | |
MB.writeName("LED_STATUS", ledstatus) | |
i = i + 1 | |
end | |
end | |
-- Set the LED operation back to normal | |
MB.writeName("POWER_LED", 1) | |
print("") | |
print("Finished") | |
-- Writing 0 to LUA_RUN stops the script | |
MB.writeName("LUA_RUN", 0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment