Pt. 2 | Encryption encrypt program

Dependencies:   mbed 4DGL-uLCD-SE SDFileSystem PinDetect

Committer:
sralph3
Date:
Thu Jan 03 22:36:11 2019 +0000
Revision:
0:35bd4a705079
Pt. 2 | Encryption decrypt program

Who changed what in which revision?

UserRevisionLine numberNew contents of line
sralph3 0:35bd4a705079 1 #include "mbed.h"
sralph3 0:35bd4a705079 2
sralph3 0:35bd4a705079 3 //Setup a new class for TMP36 sensor
sralph3 0:35bd4a705079 4 class TMP36
sralph3 0:35bd4a705079 5 {
sralph3 0:35bd4a705079 6 public:
sralph3 0:35bd4a705079 7 TMP36(PinName pin);
sralph3 0:35bd4a705079 8 TMP36();
sralph3 0:35bd4a705079 9 operator float ();
sralph3 0:35bd4a705079 10 float read();
sralph3 0:35bd4a705079 11 private:
sralph3 0:35bd4a705079 12 //class sets up the AnalogIn pin
sralph3 0:35bd4a705079 13 AnalogIn _pin;
sralph3 0:35bd4a705079 14 };
sralph3 0:35bd4a705079 15
sralph3 0:35bd4a705079 16 TMP36::TMP36(PinName pin) : _pin(pin)
sralph3 0:35bd4a705079 17 {
sralph3 0:35bd4a705079 18 // _pin(pin) means pass pin to the AnalogIn constructor
sralph3 0:35bd4a705079 19 }
sralph3 0:35bd4a705079 20
sralph3 0:35bd4a705079 21 float TMP36::read()
sralph3 0:35bd4a705079 22 {
sralph3 0:35bd4a705079 23 //convert sensor reading to temperature in degrees C
sralph3 0:35bd4a705079 24 return ((_pin.read()*3.3)-0.500)*100.0;
sralph3 0:35bd4a705079 25 }
sralph3 0:35bd4a705079 26 //overload of float conversion (avoids needing to type .read() in equations)
sralph3 0:35bd4a705079 27 TMP36::operator float ()
sralph3 0:35bd4a705079 28 {
sralph3 0:35bd4a705079 29 //convert sensor reading to temperature in degrees C
sralph3 0:35bd4a705079 30 return ((_pin.read()*3.3)-0.500)*100.0;
sralph3 0:35bd4a705079 31 }