DesignForAmputee hw 5 project
Dependencies: mbed BLE_API nRF51822
main.cpp@9:22fe2c5a62ba, 2014-11-09 (annotated)
- Committer:
- jstroud
- Date:
- Sun Nov 09 22:07:32 2014 +0000
- Revision:
- 9:22fe2c5a62ba
- Parent:
- 5:46dd21736d36
nordic test code for temperature conversion
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jstroud | 0:6a0d0bc31c4c | 1 | #include "mbed.h" |
pgao | 3:436ef162bf2d | 2 | |
jstroud | 4:0ebd5e43da47 | 3 | DigitalOut myled(LED1); |
jstroud | 4:0ebd5e43da47 | 4 | DigitalOut power(P0_0); // brown |
jstroud | 4:0ebd5e43da47 | 5 | |
jstroud | 4:0ebd5e43da47 | 6 | AnalogIn tempPin(P0_1); // purple |
jstroud | 4:0ebd5e43da47 | 7 | float temp; |
pgao | 3:436ef162bf2d | 8 | Serial pc(USBTX, USBRX); |
pgao | 3:436ef162bf2d | 9 | |
pgao | 3:436ef162bf2d | 10 | |
jstroud | 4:0ebd5e43da47 | 11 | int main() { |
jstroud | 5:46dd21736d36 | 12 | power = 1; |
jstroud | 4:0ebd5e43da47 | 13 | while(1) { |
jstroud | 4:0ebd5e43da47 | 14 | myled = 1; |
jstroud | 9:22fe2c5a62ba | 15 | //power = 1; |
jstroud | 5:46dd21736d36 | 16 | wait(0.5); |
jstroud | 9:22fe2c5a62ba | 17 | //power = 0; |
jstroud | 4:0ebd5e43da47 | 18 | myled = 0; |
jstroud | 4:0ebd5e43da47 | 19 | wait(0.2); |
jstroud | 5:46dd21736d36 | 20 | //power = 1; |
jstroud | 4:0ebd5e43da47 | 21 | temp = tempPin.read(); |
jstroud | 9:22fe2c5a62ba | 22 | float tempC = ((temp*3.0)-0.5)*100.0; // conversion to celcius |
jstroud | 9:22fe2c5a62ba | 23 | float tempF = (tempC*9.0/5.0)+32.0; // conversion to fahrenheit |
jstroud | 9:22fe2c5a62ba | 24 | pc.printf("test\n"); |
jstroud | 9:22fe2c5a62ba | 25 | pc.printf("\ntemp[V]:%f\ttemp[C]:%f\ttemp[F]:%f\t",temp,tempC,tempF); |
jstroud | 5:46dd21736d36 | 26 | //if(temp > 0.5) |
jstroud | 5:46dd21736d36 | 27 | // power = 1; |
jstroud | 0:6a0d0bc31c4c | 28 | } |
jstroud | 0:6a0d0bc31c4c | 29 | } |