![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
lab sensory - program 4
Dependencies: mbed
main_all.cpp@0:82ae1a3156c2, 2015-03-27 (annotated)
- Committer:
- Kuba_M
- Date:
- Fri Mar 27 10:54:42 2015 +0000
- Revision:
- 0:82ae1a3156c2
message 4
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Kuba_M | 0:82ae1a3156c2 | 1 | #include "mbed.h" |
Kuba_M | 0:82ae1a3156c2 | 2 | |
Kuba_M | 0:82ae1a3156c2 | 3 | int analog_zero_0 = 0; |
Kuba_M | 0:82ae1a3156c2 | 4 | int analog_zero_1 = 0; |
Kuba_M | 0:82ae1a3156c2 | 5 | int analog_zero_2 = 0; |
Kuba_M | 0:82ae1a3156c2 | 6 | int analog_zero_3 = 0; |
Kuba_M | 0:82ae1a3156c2 | 7 | int analog_zero_4 = 0; |
Kuba_M | 0:82ae1a3156c2 | 8 | int analog_zero_5 = 0; |
Kuba_M | 0:82ae1a3156c2 | 9 | AnalogIn fotorezystor(PTB0); |
Kuba_M | 0:82ae1a3156c2 | 10 | AnalogIn hallotron_silnik(PTB1); |
Kuba_M | 0:82ae1a3156c2 | 11 | AnalogIn tensometr(PTB2); |
Kuba_M | 0:82ae1a3156c2 | 12 | AnalogIn termopara(PTB3); |
Kuba_M | 0:82ae1a3156c2 | 13 | AnalogIn hallotron_prasa(PTC2); |
Kuba_M | 0:82ae1a3156c2 | 14 | AnalogIn czujnik_odleglosci(PTC1); |
Kuba_M | 0:82ae1a3156c2 | 15 | DigitalIn indukcyjny(PTA1); |
Kuba_M | 0:82ae1a3156c2 | 16 | Serial pc(USBTX, USBRX); |
Kuba_M | 0:82ae1a3156c2 | 17 | Ticker triger1; |
Kuba_M | 0:82ae1a3156c2 | 18 | |
Kuba_M | 0:82ae1a3156c2 | 19 | float voltage(AnalogIn czujnik, float zero_analog) { |
Kuba_M | 0:82ae1a3156c2 | 20 | return (czujnik.read() - zero_analog) * 2.9035; |
Kuba_M | 0:82ae1a3156c2 | 21 | } |
Kuba_M | 0:82ae1a3156c2 | 22 | |
Kuba_M | 0:82ae1a3156c2 | 23 | void task1(int k) { |
Kuba_M | 0:82ae1a3156c2 | 24 | pc.printf("%d\t%.3f\t%.3f\t%.3f\t\%.3f\t\%.3f\t%.3f\t\n", k, voltage(fotorezystor, analog_zero_0), |
Kuba_M | 0:82ae1a3156c2 | 25 | voltage(hallotron_silnik, analog_zero_1), |
Kuba_M | 0:82ae1a3156c2 | 26 | voltage(tensometr, analog_zero_2), |
Kuba_M | 0:82ae1a3156c2 | 27 | voltage(termopara, analog_zero_3), |
Kuba_M | 0:82ae1a3156c2 | 28 | voltage(hallotron_prasa, analog_zero_4), |
Kuba_M | 0:82ae1a3156c2 | 29 | voltage(czujnik_odleglosci, analog_zero_5)); |
Kuba_M | 0:82ae1a3156c2 | 30 | } |
Kuba_M | 0:82ae1a3156c2 | 31 | |
Kuba_M | 0:82ae1a3156c2 | 32 | |
Kuba_M | 0:82ae1a3156c2 | 33 | |
Kuba_M | 0:82ae1a3156c2 | 34 | int main() { |
Kuba_M | 0:82ae1a3156c2 | 35 | pc.baud(9600); |
Kuba_M | 0:82ae1a3156c2 | 36 | int k=0; |
Kuba_M | 0:82ae1a3156c2 | 37 | |
Kuba_M | 0:82ae1a3156c2 | 38 | while (true) { |
Kuba_M | 0:82ae1a3156c2 | 39 | |
Kuba_M | 0:82ae1a3156c2 | 40 | k++; |
Kuba_M | 0:82ae1a3156c2 | 41 | wait_ms(100); |
Kuba_M | 0:82ae1a3156c2 | 42 | task1(k); |
Kuba_M | 0:82ae1a3156c2 | 43 | } |
Kuba_M | 0:82ae1a3156c2 | 44 | } |