CdoubleOK

Speed Control

Apr 10th, 2023 (edited)
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local modem = peripheral.find("modem")
  2. local monitor = peripheral.wrap("front")
  3.  
  4. monitor.clear()
  5. monitor.setCursorPos(1,1)
  6. monitor.setTextScale(0.5)
  7. term.clear()
  8. term.setCursorPos(1,1)
  9. print("Running...")
  10.  
  11.  
  12. local function shift(side, mode, bgc, tc)
  13.   rs.setOutput(side,true)
  14.   modem.transmit(2,3,mode)
  15.   monitor.setCursorPos(1,1)
  16.   monitor.clear()
  17.   monitor.setBackgroundColor(bgc)
  18.   monitor.setTextColor(tc)
  19.   monitor.setCursorPos(8, 4)
  20.   monitor.write("Automated Power Control")
  21.   monitor.setCursorPos(8, 5)
  22.   monitor.write("-=-=-=-=-=-=-=-=-=-=-=-")
  23.   monitor.setCursorPos(8, 6)
  24.   monitor.write(mode)
  25.   sleep(1)
  26.   rs.setOutput(side,false)
  27.   term.setCursorPos(1,3)
  28. end
  29.  
  30. while rs.getInput("front") == false
  31. do
  32.  
  33. local speed = rs.getAnalogInput("top")
  34.  
  35. if speed == 15
  36. then
  37. shift ("right", "Full Power", colors.green, colors.white)
  38. end
  39.  
  40. if speed == 14
  41. then
  42. shift ("back", "Low Power", colors.blue, colors.white)
  43. end
  44.  
  45. if speed == 9
  46. then
  47. shift ("left", "Standby", colors.yellow, colors.black)
  48. end
  49.  
  50. if speed == 8
  51. then
  52. shift ("bottom", "Offline", colors.red, colors.white)
  53. end
  54.  
  55. end
Add Comment
Please, Sign In to add comment