Test Code
Dependencies: mbed
Diff: main.cpp
- Revision:
- 1:64d0588f103d
- Parent:
- 0:f9d4d60a303f
- Child:
- 2:4b534d899254
--- a/main.cpp Mon Apr 15 14:23:12 2019 +0000 +++ b/main.cpp Tue Apr 16 14:14:30 2019 +0000 @@ -1,12 +1,22 @@ #include "mbed.h" -DigitalOut myled(LED1); +Serial pc(USBTX,USBRX); -int main() { - while(1) { - myled = 1; - wait(0.2); - myled = 0; - wait(0.2); - } +DigitalIn hall(p21); +DigitalOut hallpwr(p22); +DigitalOut myled(LED1); +int i; +int main() +{ + hall.mode(PullUp); + hallpwr=1; + i=hall.read(); + if (i==1) { + printf("Magnet\n\r"); + myled=1; + } else { + printf("No magnet\n\r"); + myled=0; + } } +