pressure control

Signed-off-by: Superkooka <aymeric.gueracague@gmail.com>
This commit is contained in:
Aymeric GUERACAGUE 2025-06-21 18:14:30 +02:00
parent 01cd151e81
commit 2ca5fa463e
Signed by: Superkooka
GPG Key ID: F78F2B172E894865
1 changed files with 36 additions and 0 deletions

View File

@ -0,0 +1,36 @@
local computer = require("computer")
local rs = require("component").redstone
local sides = require("sides")
local lastPowerValue = -1
local compressorState = false
local cutValue = 8
print("The cut value is fixed at " .. cutValue .. ". At this value, it will automatically stop compressor.")
while true do
local power = rs.getInput(sides.back)
if power ~= lastPowerValue then
lastPowerValue = power
print("[" ..
os.date():sub(9) .. "]" .. " Current redstone value: " .. power .. "/16.0 (" .. power / 2 .. "BAR +-)")
end
if (power < cutValue) then
rs.setOutput(sides.left, 14)
if compressorState ~= true then
print("[" .. os.date():sub(9) .. "]" .. " Turning ON compressor...")
compressorState = true
computer.beep()
end
else
rs.setOutput(sides.left, 0)
if compressorState ~= false then
print("[" .. os.date():sub(9) .. "]" .. " Turning OFF compressor...")
compressorState = false
computer.beep()
end
end
os.sleep(2)
end