digital input example of CORE-1000
Dependencies: mbed
main.cpp@2:fe6a81c5e6b8, 2019-01-09 (annotated)
- Committer:
- odb
- Date:
- Wed Jan 09 04:24:37 2019 +0000
- Revision:
- 2:fe6a81c5e6b8
- Parent:
- 1:4a3198da4fe1
Digital Sensor test for the CORE-1000
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
gcarmonar | 0:802145a6ea33 | 1 | #include "mbed.h" |
gcarmonar | 0:802145a6ea33 | 2 | |
gcarmonar | 0:802145a6ea33 | 3 | |
odb | 2:fe6a81c5e6b8 | 4 | //DigitalOut mybuzzer(PC_4); |
odb | 2:fe6a81c5e6b8 | 5 | //PwmOut mypwmR(PB_5); |
odb | 2:fe6a81c5e6b8 | 6 | //PwmOut mypwmG(PB_3); |
odb | 2:fe6a81c5e6b8 | 7 | //PwmOut mypwmB(PA_10); |
odb | 2:fe6a81c5e6b8 | 8 | DigitalOut myled[4] = { PC_9, PB_2, PC_2, PC_3}; |
odb | 2:fe6a81c5e6b8 | 9 | |
odb | 2:fe6a81c5e6b8 | 10 | DigitalIn Sensor_DIN(PA_6); |
odb | 2:fe6a81c5e6b8 | 11 | Serial pc(USBTX, USBRX); // tx, rx |
gcarmonar | 0:802145a6ea33 | 12 | int main() { |
odb | 2:fe6a81c5e6b8 | 13 | pc.baud(115200); |
odb | 2:fe6a81c5e6b8 | 14 | pc.printf("\n Sensor Digital InPut example\n"); |
gcarmonar | 0:802145a6ea33 | 15 | while(1) { |
odb | 1:4a3198da4fe1 | 16 | if (Sensor_DIN == 0){ |
odb | 2:fe6a81c5e6b8 | 17 | myled[0] = 1; |
odb | 2:fe6a81c5e6b8 | 18 | pc.printf("sensor detected \n\r"); |
odb | 1:4a3198da4fe1 | 19 | } |
odb | 1:4a3198da4fe1 | 20 | else{ |
odb | 2:fe6a81c5e6b8 | 21 | myled[0] = 0; |
gcarmonar | 0:802145a6ea33 | 22 | } |
gcarmonar | 0:802145a6ea33 | 23 | } |
gcarmonar | 0:802145a6ea33 | 24 | } |