1

Dependencies:   UiSM_Lab_5_pomiary mbed

Fork of L5_odczyt by abm mechatronika

Committer:
Pawel_13
Date:
Fri Apr 17 14:48:48 2015 +0000
Revision:
0:e7d867077aec
UiSM Lab 5 17.04.2015

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Pawel_13 0:e7d867077aec 1 #include "mbed.h"
Pawel_13 0:e7d867077aec 2
Pawel_13 0:e7d867077aec 3 int analog_zero_0 = 0;
Pawel_13 0:e7d867077aec 4 int analog_zero_1 = 0;
Pawel_13 0:e7d867077aec 5 int analog_zero_2 = 0;
Pawel_13 0:e7d867077aec 6 int analog_zero_3 = 0;
Pawel_13 0:e7d867077aec 7 int analog_zero_4 = 0;
Pawel_13 0:e7d867077aec 8 int analog_zero_5 = 0;
Pawel_13 0:e7d867077aec 9 AnalogIn fotorezystor(PTB0);
Pawel_13 0:e7d867077aec 10 AnalogIn hallotron_silnik(PTB1);
Pawel_13 0:e7d867077aec 11 AnalogIn tensometr(PTB2);
Pawel_13 0:e7d867077aec 12 AnalogIn termopara(PTB3);
Pawel_13 0:e7d867077aec 13 AnalogIn hallotron_prasa(PTC2);
Pawel_13 0:e7d867077aec 14 AnalogIn czujnik_odleglosci(PTC1);
Pawel_13 0:e7d867077aec 15 DigitalIn indukcyjny(PTA1);
Pawel_13 0:e7d867077aec 16 Serial pc(USBTX, USBRX);
Pawel_13 0:e7d867077aec 17 Ticker triger1;
Pawel_13 0:e7d867077aec 18
Pawel_13 0:e7d867077aec 19 float voltage(AnalogIn czujnik, float zero_analog) {
Pawel_13 0:e7d867077aec 20 return (czujnik.read() - zero_analog) * 2.9035;
Pawel_13 0:e7d867077aec 21 }
Pawel_13 0:e7d867077aec 22
Pawel_13 0:e7d867077aec 23 void task1(int k) {
Pawel_13 0:e7d867077aec 24 pc.printf("%d\t%.3f\t%.3f\t%.3f\t%.3f\t%.3f\t%.3f\n\r", k, voltage(fotorezystor, analog_zero_0),
Pawel_13 0:e7d867077aec 25 voltage(hallotron_silnik, analog_zero_1),
Pawel_13 0:e7d867077aec 26 voltage(tensometr, analog_zero_2),
Pawel_13 0:e7d867077aec 27 voltage(termopara, analog_zero_3),
Pawel_13 0:e7d867077aec 28 voltage(hallotron_prasa, analog_zero_4),
Pawel_13 0:e7d867077aec 29 voltage(czujnik_odleglosci, analog_zero_5));
Pawel_13 0:e7d867077aec 30 }
Pawel_13 0:e7d867077aec 31
Pawel_13 0:e7d867077aec 32
Pawel_13 0:e7d867077aec 33
Pawel_13 0:e7d867077aec 34 int main() {
Pawel_13 0:e7d867077aec 35 pc.baud(9600);
Pawel_13 0:e7d867077aec 36 int k=0;
Pawel_13 0:e7d867077aec 37
Pawel_13 0:e7d867077aec 38 while (true) {
Pawel_13 0:e7d867077aec 39
Pawel_13 0:e7d867077aec 40 k++;
Pawel_13 0:e7d867077aec 41 wait_ms(100);
Pawel_13 0:e7d867077aec 42 task1(k);
Pawel_13 0:e7d867077aec 43 }
Pawel_13 0:e7d867077aec 44 }