-
TrafficLight2.cpp@0:dd85f9c232ac, 2020-11-26 (annotated)
- Committer:
- divicic
- Date:
- Thu Nov 26 07:51:56 2020 +0000
- Revision:
- 0:dd85f9c232ac
-
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
divicic | 0:dd85f9c232ac | 1 | #include "TrafficLight2.h" |
divicic | 0:dd85f9c232ac | 2 | #include "mbed.h" |
divicic | 0:dd85f9c232ac | 3 | TrafficLight2::TrafficLight2(PinName pin) : _pin(pin) |
divicic | 0:dd85f9c232ac | 4 | { |
divicic | 0:dd85f9c232ac | 5 | _pin = 0; |
divicic | 0:dd85f9c232ac | 6 | } |
divicic | 0:dd85f9c232ac | 7 | void TrafficLight2::flash(int n) |
divicic | 0:dd85f9c232ac | 8 | { |
divicic | 0:dd85f9c232ac | 9 | for(int i=0; i<n*2; i++) { |
divicic | 0:dd85f9c232ac | 10 | _pin = !_pin; |
divicic | 0:dd85f9c232ac | 11 | } |
divicic | 0:dd85f9c232ac | 12 | } |
divicic | 0:dd85f9c232ac | 13 | void TrafficLight2::On () |
divicic | 0:dd85f9c232ac | 14 | { |
divicic | 0:dd85f9c232ac | 15 | _pin = 1; |
divicic | 0:dd85f9c232ac | 16 | } |
divicic | 0:dd85f9c232ac | 17 | void TrafficLight2::Off () |
divicic | 0:dd85f9c232ac | 18 | { |
divicic | 0:dd85f9c232ac | 19 | _pin = 0; |
divicic | 0:dd85f9c232ac | 20 | } |