SHOW:
|
|
- or go back to the newest paste.
1 | --Ascensore (C) lego11 | |
2 | ||
3 | altezza = 57 | |
4 | ||
5 | function clear() | |
6 | term.clear() | |
7 | term.setCursorPos(1, 1) | |
8 | print("PLC ASCENSORE (C) lego11 2018") | |
9 | print("") | |
10 | end | |
11 | ||
12 | function sali() | |
13 | clear() | |
14 | print("Salita in corso") | |
15 | redstone.setOutput("right", true) | |
16 | sleep(0.2) | |
17 | redstone.setOutput("right", false) | |
18 | sleep(1) | |
19 | for i=1,altezza do | |
20 | redstone.setOutput("right", true) | |
21 | sleep(0.2) | |
22 | redstone.setOutput("right", false) | |
23 | sleep(0.6) | |
24 | end | |
25 | end | |
26 | ||
27 | function scendi() | |
28 | clear() | |
29 | print("Discesa in corso") | |
30 | redstone.setOutput("left", true) | |
31 | sleep(0.2) | |
32 | redstone.setOutput("left", false) | |
33 | sleep(1) | |
34 | for i=1,altezza do | |
35 | redstone.setOutput("left", true) | |
36 | sleep(0.2) | |
37 | redstone.setOutput("left", false) | |
38 | sleep(0.6) | |
39 | end | |
40 | end | |
41 | ||
42 | while true do | |
43 | clear() | |
44 | print("Attesa") | |
45 | os.pullEvent("redstone") | |
46 | if rs.getInput("bottom") == true then | |
47 | if rs.getInput("top") == true then | |
48 | sali() | |
49 | else | |
50 | scendi() | |
51 | end | |
52 | sleep(2) | |
53 | end | |
54 | end |