Created
April 26, 2021 02:27
-
-
Save futureshocked/4f21c06eea679bd443789965afba45d0 to your computer and use it in GitHub Desktop.
This script shows how to control an LED with FIO5 with a Lua script.
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.50 - blink_LED_FIO5.lua | |
This script shows how to control an LED with FIO5 with a Lua script. | |
Components | |
---------- | |
- LabJack T4 | |
- LED | |
- Cathode (short pin) to GND | |
- Anode (long pin) to FIO5 | |
- Wires | |
- Breadboard | |
Course | |
------ | |
Data acquisition and automation with LabJack | |
https://app.techexplorations.com/courses/labjack/ | |
--]] | |
--- Original: https://labjack.com/support/software/examples/lua-scripting/toggle-dio | |
print("Toggle the digital I/O called FIO5 at 1 Hz. Generates a 0.5Hz square wave.") | |
local outpin = 2005 -- This is FIO5, as can be seen with the help of the Register Matrix | |
local devtype = MB.readName("PRODUCT_ID") | |
print("Device type: ", devtype) | |
local diostatus = 0 | |
local mbWrite=MB.W -- assign the W (write) function to a local variable | |
-- Configure a 1000ms interval | |
LJ.IntervalConfig(0, 1000) | |
while true do | |
-- If an interval is done | |
if LJ.CheckInterval(0) then | |
-- If the DIO pin is set high | |
if diostatus == 1 then | |
-- Set the DIO pin low | |
diostatus = 0 | |
print(diostatus, "low") | |
else | |
-- Set the DIO pin high | |
diostatus = 1 | |
print(diostatus, "high") | |
end | |
-- Apply the change to the DIO pin register (toggle on or off) | |
mbWrite(outpin, 0, diostatus) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment