James Pang
/
YIC_day_2
YIC day 2
main.cpp@0:76b2279d6a55, 2015-04-02 (annotated)
- Committer:
- lingtien5846
- Date:
- Thu Apr 02 05:12:58 2015 +0000
- Revision:
- 0:76b2279d6a55
YIC day 2
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
lingtien5846 | 0:76b2279d6a55 | 1 | #include "mbed.h" |
lingtien5846 | 0:76b2279d6a55 | 2 | #include "TransmitterIR.h" |
lingtien5846 | 0:76b2279d6a55 | 3 | |
lingtien5846 | 0:76b2279d6a55 | 4 | DigitalOut lpc1768_led_1(LED1); |
lingtien5846 | 0:76b2279d6a55 | 5 | DigitalOut grove_button(p20); |
lingtien5846 | 0:76b2279d6a55 | 6 | |
lingtien5846 | 0:76b2279d6a55 | 7 | TransmitterIR ir_tx(p21); |
lingtien5846 | 0:76b2279d6a55 | 8 | |
lingtien5846 | 0:76b2279d6a55 | 9 | int main() { |
lingtien5846 | 0:76b2279d6a55 | 10 | lpc1768_led_1 = 0; |
lingtien5846 | 0:76b2279d6a55 | 11 | while(1) { |
lingtien5846 | 0:76b2279d6a55 | 12 | if (grove_button) { |
lingtien5846 | 0:76b2279d6a55 | 13 | lpc1768_led_1 = 1; |
lingtien5846 | 0:76b2279d6a55 | 14 | |
lingtien5846 | 0:76b2279d6a55 | 15 | RemoteIR::Format format = RemoteIR::SONY; |
lingtien5846 | 0:76b2279d6a55 | 16 | uint8_t buf[] = { 0x80, 0x00 }; |
lingtien5846 | 0:76b2279d6a55 | 17 | int bitcount = 12; |
lingtien5846 | 0:76b2279d6a55 | 18 | if (ir_tx.getState() == TransmitterIR::Idle) { |
lingtien5846 | 0:76b2279d6a55 | 19 | bitcount = ir_tx.setData(format, buf, bitcount); |
lingtien5846 | 0:76b2279d6a55 | 20 | } |
lingtien5846 | 0:76b2279d6a55 | 21 | } |
lingtien5846 | 0:76b2279d6a55 | 22 | lpc1768_led_1 = 0; |
lingtien5846 | 0:76b2279d6a55 | 23 | } |
lingtien5846 | 0:76b2279d6a55 | 24 | } |