Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Radio Control v1 by Gazer29
- local component = require("component")
- local term = require ("term")
- local trainRemote = component.ir_remote_control
- local RUNNING = true
- local flag = false
- function helpdisplay()
- print("Radio Control v1")
- print("Commands:")
- print("'Any number' - Changes Throttle")
- print("'stop' - Ends program")
- end
- ----------- Main loop ------------
- trainRemote.setBrake(0)
- while RUNNING do
- term.clear()
- helpdisplay()
- user = nil
- user = io.read()
- if user == "stop" then
- print("STOPPING...")
- os.sleep(1)
- RUNNING = false
- term.clear()
- end
- if user == "h" then
- print("Horn")
- trainRemote.horn()
- end
- if user == "b" then
- print("Bell")
- if flag == false then
- trainRemote.bell(1)
- flag = true
- else
- trainRemote.bell(0)
- flag = false
- end
- end
- if nil ~= tonumber(user) then
- input = tonumber(user)
- if -1 <= input and input <= 1 then
- print("Setting Throttle: ", user)
- trainRemote.setThrottle(input)
- end
- end
- os.sleep(0.5)
- end
- trainRemote.setThrottle(0)
- trainRemote.setBrake(1)
Add Comment
Please, Sign In to add comment