k

Dependencies:   mbed

Committer:
RobotManYt
Date:
Fri May 24 14:38:11 2019 +0000
Revision:
0:6c538ba03807
l

Who changed what in which revision?

UserRevisionLine numberNew contents of line
RobotManYt 0:6c538ba03807 1 #include "mbed.h"
RobotManYt 0:6c538ba03807 2
RobotManYt 0:6c538ba03807 3 AnalogIn analog_value(A0); // Définition broche analogique sur PA_0
RobotManYt 0:6c538ba03807 4 Serial pc(SERIAL_TX, SERIAL_RX); // Définition d'un port série avec l'ordinateur
RobotManYt 0:6c538ba03807 5 Ticker printTMP; // Définition d'un ticker
RobotManYt 0:6c538ba03807 6
RobotManYt 0:6c538ba03807 7 uint8_t tmp = 0; // Définition variable tmp; GLOBAL; tmp = Température
RobotManYt 0:6c538ba03807 8
RobotManYt 0:6c538ba03807 9 void print(){
RobotManYt 0:6c538ba03807 10 pc.printf("Temperature = %u C", tmp); // Affiche tmp/température
RobotManYt 0:6c538ba03807 11 }
RobotManYt 0:6c538ba03807 12
RobotManYt 0:6c538ba03807 13 int main() {
RobotManYt 0:6c538ba03807 14 printTMP.attach(&print, 0.2);
RobotManYt 0:6c538ba03807 15
RobotManYt 0:6c538ba03807 16 while(1) {
RobotManYt 0:6c538ba03807 17 int16_t meas = analog_value.read() * 3300; // Lecture du port analogique
RobotManYt 0:6c538ba03807 18 tmp = (uint8_t)(((float)meas / 10) - 273.15); // mV --> °C
RobotManYt 0:6c538ba03807 19 }
RobotManYt 0:6c538ba03807 20 }