Pt. 4 | Encryption encrypt program

Dependencies:   mbed 4DGL-uLCD-SE SDFileSystem PinDetect

Committer:
sralph3
Date:
Thu Jan 03 22:40:26 2019 +0000
Revision:
0:72aeef60e1fc
Pt. 4 | Encryption encrypt program

Who changed what in which revision?

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