
make public
main.cpp@0:2703fee61906, 2021-03-26 (annotated)
- Committer:
- BertieHarte
- Date:
- Fri Mar 26 10:17:07 2021 +0000
- Revision:
- 0:2703fee61906
make public
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
BertieHarte | 0:2703fee61906 | 1 | #include "mbed.h" |
BertieHarte | 0:2703fee61906 | 2 | // Initializes a pin to perform analog input and digital outpuut functions |
BertieHarte | 0:2703fee61906 | 3 | AnalogIn aInput(p19) // pot 1 on the application board |
BertieHarte | 0:2703fee61906 | 4 | DigitalOut dOutput(LED1); |
BertieHarte | 0:2703fee61906 | 5 | |
BertieHarte | 0:2703fee61906 | 6 | int main(void) { |
BertieHarte | 0:2703fee61906 | 7 | while(1) { |
BertieHarte | 0:2703fee61906 | 8 | //test the voltage on the initialized analog pin |
BertieHarte | 0:2703fee61906 | 9 | // if greater than 0.3 * VCC set the digital pin |
BertieHarte | 0:2703fee61906 | 10 | // to a logic 1 otherwise set to logic 0 |
BertieHarte | 0:2703fee61906 | 11 | if (aInput > 0.3f) { |
BertieHarte | 0:2703fee61906 | 12 | dOutput = 1; |
BertieHarte | 0:2703fee61906 | 13 | } else { |
BertieHarte | 0:2703fee61906 | 14 | dOutput = 0; |
BertieHarte | 0:2703fee61906 | 15 | } |
BertieHarte | 0:2703fee61906 | 16 | } |
BertieHarte | 0:2703fee61906 | 17 | } |