![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
project van rtos
Dependencies: mbed-os
Fork of MFRC522 by
Diff: main.cpp
- Revision:
- 4:325954591d0f
- Parent:
- 3:80837b470692
- Child:
- 5:e45681989201
diff -r 80837b470692 -r 325954591d0f main.cpp --- a/main.cpp Tue May 08 12:52:09 2018 +0000 +++ b/main.cpp Tue May 15 11:22:14 2018 +0000 @@ -1,6 +1,7 @@ #include "mbed.h" #include "MFRC522.h" +#include "rtos.h" //KL25Z Pins for MFRC522 SPI interface #define SPI_MOSI p5 @@ -36,6 +37,8 @@ AnalogIn a0(p20); +float sensorValue = 0; + int sevenSeg; void light7Seg(int nr, int output) { @@ -245,8 +248,27 @@ } } +void samplePotentio() { + while (true) { + float samples[20]; + float sum = 0; + for(int i = 0; i < 20; i++) { + samples[i] = a0.read(); + wait_ms(10); + } + for (int i = 0; i < 9; i++) { + sum = sum + samples[i]; + } + sensorValue = sum / 20; + } +} + int main(void) { pc.printf("Start"); + + Thread thread_display; + thread_display.start(samplePotentio); + // Set debug UART speed //pc.baud(115200); @@ -261,7 +283,7 @@ while (true) { led = 0; - displayNumber7Seg(a0.read()); + displayNumber7Seg(sensorValue); //printf("%0.4f \n\r", a0.read()); // Look for new cards