Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Speed Controller
- --Consts--
- local motor = peripheral.find("electric_motor")
- term.clear()
- term.scroll(-2)
- while true do
- term.scroll(-1)
- print("Enter Speed: ")
- local input = read()
- if input:match("^%-?%d+$") then
- local num = tonumber(input, 10)
- if num > 256 or num < -256 then
- print("[ERROR]: Invalid Number, Number must be between 256 and -256")
- else
- motor.setSpeed(num)
- print("[INFO]: Speed was successfully set to " .. num)
- end
- else
- print("[ERROR]: Input was not a number.")
- end
- sleep(2)
- term.clear()
- end
Advertisement
Add Comment
Please, Sign In to add comment