Russell Shomberg
/
shomberg_hw_6
HW6 for OCE560
Fork of shomberg_hw_5 by
OCE360Input.cpp@9:da0b72918880, 2018-10-25 (annotated)
- Committer:
- rshomberg
- Date:
- Thu Oct 25 18:12:33 2018 +0000
- Revision:
- 9:da0b72918880
- Child:
- 11:42914083ac70
does not compile
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
rshomberg | 9:da0b72918880 | 1 | /** |
rshomberg | 9:da0b72918880 | 2 | Temperature Sensor and Switch Read |
rshomberg | 9:da0b72918880 | 3 | OCE360Input.cpp |
rshomberg | 9:da0b72918880 | 4 | |
rshomberg | 9:da0b72918880 | 5 | Purpose: Read a switch connected at p7 |
rshomberg | 9:da0b72918880 | 6 | Read a temperature sensor connected at p20 |
rshomberg | 9:da0b72918880 | 7 | |
rshomberg | 9:da0b72918880 | 8 | @author Russell Shomberg |
rshomberg | 9:da0b72918880 | 9 | @created 2018-10-25 |
rshomberg | 9:da0b72918880 | 10 | @revised 2018-10-25 |
rshomberg | 9:da0b72918880 | 11 | @version 0.0 |
rshomberg | 9:da0b72918880 | 12 | |
rshomberg | 9:da0b72918880 | 13 | Issues: |
rshomberg | 9:da0b72918880 | 14 | |
rshomberg | 9:da0b72918880 | 15 | */ |
rshomberg | 9:da0b72918880 | 16 | // INCLUDES |
rshomberg | 9:da0b72918880 | 17 | #include "mbed.h" |
rshomberg | 9:da0b72918880 | 18 | #include "OCE360Input.h" |
rshomberg | 9:da0b72918880 | 19 | |
rshomberg | 9:da0b72918880 | 20 | // DEFINES |
rshomberg | 9:da0b72918880 | 21 | #define VREF 3.5 |
rshomberg | 9:da0b72918880 | 22 | #define TEMP_CALIBRATION_A 0.01 |
rshomberg | 9:da0b72918880 | 23 | #define TEMP_CALIBRATION_B 0 |
rshomberg | 9:da0b72918880 | 24 | |
rshomberg | 9:da0b72918880 | 25 | int read_switch(void) { |
rshomberg | 9:da0b72918880 | 26 | return myswitch; |
rshomberg | 9:da0b72918880 | 27 | } |
rshomberg | 9:da0b72918880 | 28 | |
rshomberg | 9:da0b72918880 | 29 | float read_sensor(void){ |
rshomberg | 9:da0b72918880 | 30 | return Ain*VREF*1000; |
rshomberg | 9:da0b72918880 | 31 | } |
rshomberg | 9:da0b72918880 | 32 | |
rshomberg | 9:da0b72918880 | 33 | float convert_mV_to_temp(int sensorVoltage) { |
rshomberg | 9:da0b72918880 | 34 | return sensorVoltage*TEMP_CALIBRATION_A+TEMP_CALIBRATION_B; |
rshomberg | 9:da0b72918880 | 35 | } |