InterruptIn örneği

Fork of InterruptIn_HelloWorld by mbed_example

Committer:
mbedAustin
Date:
Fri Mar 27 20:14:27 2015 +0000
Revision:
2:dc8472f90484
Parent:
0:7a20a6aa1f5e
Child:
3:f729f0421740
Added license to main.c file.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbedAustin 2:dc8472f90484 1 /* mbed Example Program
mbedAustin 2:dc8472f90484 2 * Copyright (c) 2006-2014 ARM Limited
mbedAustin 2:dc8472f90484 3 *
mbedAustin 2:dc8472f90484 4 * Licensed under the Apache License, Version 2.0 (the "License");
mbedAustin 2:dc8472f90484 5 * you may not use this file except in compliance with the License.
mbedAustin 2:dc8472f90484 6 * You may obtain a copy of the License at
mbedAustin 2:dc8472f90484 7 *
mbedAustin 2:dc8472f90484 8 * http://www.apache.org/licenses/LICENSE-2.0
mbedAustin 2:dc8472f90484 9 *
mbedAustin 2:dc8472f90484 10 * Unless required by applicable law or agreed to in writing, software
mbedAustin 2:dc8472f90484 11 * distributed under the License is distributed on an "AS IS" BASIS,
mbedAustin 2:dc8472f90484 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
mbedAustin 2:dc8472f90484 13 * See the License for the specific language governing permissions and
mbedAustin 2:dc8472f90484 14 * limitations under the License.
mbedAustin 2:dc8472f90484 15 */
mbed_official 0:7a20a6aa1f5e 16 #include "mbed.h"
mbed_official 0:7a20a6aa1f5e 17
mbed_official 0:7a20a6aa1f5e 18 InterruptIn button(p5);
mbed_official 0:7a20a6aa1f5e 19 DigitalOut led(LED1);
mbed_official 0:7a20a6aa1f5e 20 DigitalOut flash(LED4);
mbed_official 0:7a20a6aa1f5e 21
mbed_official 0:7a20a6aa1f5e 22 void flip() {
mbed_official 0:7a20a6aa1f5e 23 led = !led;
mbed_official 0:7a20a6aa1f5e 24 }
mbed_official 0:7a20a6aa1f5e 25
mbed_official 0:7a20a6aa1f5e 26 int main() {
mbed_official 0:7a20a6aa1f5e 27 button.rise(&flip); // attach the address of the flip function to the rising edge
mbed_official 0:7a20a6aa1f5e 28 while(1) { // wait around, interrupts will interrupt this!
mbed_official 0:7a20a6aa1f5e 29 flash = !flash;
mbed_official 0:7a20a6aa1f5e 30 wait(0.25);
mbed_official 0:7a20a6aa1f5e 31 }
mbed_official 0:7a20a6aa1f5e 32 }