This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
greennou99's profile picture

trouble with inputs

Started by greennou99, 18 October 2012 - 05:59 PM
greennou99 #1
Posted 18 October 2012 - 07:59 PM
Im trying to create a simple program that means when a redstone input is detected on the left it pulses twice on the right but am failing miserably, please can someone help? thanks for your time.
Noodle #2
Posted 18 October 2012 - 08:01 PM
Here
function pulse()
  rs.setOutput("right", true)
  sleep(1)
  rs.setOutput("right", false)
end
while true do
  if rs.getInput("left") then
    pulse()
    pulse()
  end
end
greennou99 #3
Posted 18 October 2012 - 08:07 PM
getting an error startup:5: too long without yielding? thanks for the help :P/>/>
Noodle #4
Posted 18 October 2012 - 08:12 PM
Ah
Add sleep(0) under the 'while true do'
greennou99 #5
Posted 18 October 2012 - 08:14 PM
thanks :P/>/>
Orwell #6
Posted 18 October 2012 - 08:22 PM
Here
function pulse()
  rs.setOutput("right", true)
  sleep(1)
  rs.setOutput("right", false)
end
while true do
  if rs.getInput("left") then
	pulse()
	pulse()
  end
end

Won't that pulse once? As you don't sleep after rs.setOutput("right", false).
greennou99 #7
Posted 18 October 2012 - 08:27 PM
no since the function is down twice i think that is why it repeats, at any rate it does work