movimiento cabina
elevator.cpp@1:da94bffcc0d9, 2018-06-06 (annotated)
- Committer:
- Hedizxom
- Date:
- Wed Jun 06 20:13:43 2018 +0000
- Revision:
- 1:da94bffcc0d9
- Parent:
- 0:e6eb579c2a24
cabina;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Hedizxom | 0:e6eb579c2a24 | 1 | #include "elevator.h" |
Hedizxom | 0:e6eb579c2a24 | 2 | #include "mbed.h" |
Hedizxom | 0:e6eb579c2a24 | 3 | |
Hedizxom | 0:e6eb579c2a24 | 4 | Elevator::Elevator(PinName enable_, PinName up_, PinName down_): enable(enable_), up(up_), down(down_){ |
Hedizxom | 0:e6eb579c2a24 | 5 | enable = 0; |
Hedizxom | 0:e6eb579c2a24 | 6 | } |
Hedizxom | 0:e6eb579c2a24 | 7 | |
Hedizxom | 0:e6eb579c2a24 | 8 | void Elevator::go_up() { |
Hedizxom | 0:e6eb579c2a24 | 9 | enable.period_ms(50); |
Hedizxom | 0:e6eb579c2a24 | 10 | enable.pulsewidth_us(3500); |
Hedizxom | 0:e6eb579c2a24 | 11 | Thread::wait(1); |
Hedizxom | 0:e6eb579c2a24 | 12 | up = 1; |
Hedizxom | 0:e6eb579c2a24 | 13 | down = 0; |
Hedizxom | 0:e6eb579c2a24 | 14 | } |
Hedizxom | 0:e6eb579c2a24 | 15 | |
Hedizxom | 0:e6eb579c2a24 | 16 | void Elevator::go_down() { |
Hedizxom | 0:e6eb579c2a24 | 17 | enable.period_ms(50); |
Hedizxom | 0:e6eb579c2a24 | 18 | enable.pulsewidth_us(400); |
Hedizxom | 0:e6eb579c2a24 | 19 | Thread::wait(1); |
Hedizxom | 0:e6eb579c2a24 | 20 | up = 0; |
Hedizxom | 0:e6eb579c2a24 | 21 | down = 1; |
Hedizxom | 0:e6eb579c2a24 | 22 | } |
Hedizxom | 0:e6eb579c2a24 | 23 | |
Hedizxom | 0:e6eb579c2a24 | 24 | void Elevator::off() { |
Hedizxom | 0:e6eb579c2a24 | 25 | up = 0; |
Hedizxom | 0:e6eb579c2a24 | 26 | down = 0; |
Hedizxom | 0:e6eb579c2a24 | 27 | } |
Hedizxom | 0:e6eb579c2a24 | 28 |