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_5 = 0;
Pawel_13 0:e7d867077aec 4 AnalogIn czujnik_odleglosci(PTC1);
Pawel_13 0:e7d867077aec 5 Serial pc(USBTX, USBRX);
Pawel_13 0:e7d867077aec 6
Pawel_13 0:e7d867077aec 7 float voltage(AnalogIn czujnik, float zero_analog) {
Pawel_13 0:e7d867077aec 8 return (czujnik.read() - zero_analog) * 2.9035;
Pawel_13 0:e7d867077aec 9 }
Pawel_13 0:e7d867077aec 10
Pawel_13 0:e7d867077aec 11 void task1(int k) {
Pawel_13 0:e7d867077aec 12 pc.printf("%d\t%.3f\n\r", k, voltage(czujnik_odleglosci, analog_zero_5));
Pawel_13 0:e7d867077aec 13 }
Pawel_13 0:e7d867077aec 14
Pawel_13 0:e7d867077aec 15 int main() {
Pawel_13 0:e7d867077aec 16 pc.baud(9600);
Pawel_13 0:e7d867077aec 17 int k=0;
Pawel_13 0:e7d867077aec 18
Pawel_13 0:e7d867077aec 19 while (true) {
Pawel_13 0:e7d867077aec 20
Pawel_13 0:e7d867077aec 21 k++;
Pawel_13 0:e7d867077aec 22 wait_ms(1000);
Pawel_13 0:e7d867077aec 23 task1(k);
Pawel_13 0:e7d867077aec 24 }
Pawel_13 0:e7d867077aec 25 }