Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<arduinoPlatform.h>
- #include<tasks.h>
- #include<interrupts.h>
- #include<stdio.h>
- #include<serial.h>
- #include<pwm.h>
- extern serial Serial;
- #define pocetenciometar A0
- int x=0;
- void citanje(int n,void *tptr){
- int vrednost_potenciometra=analogRead(A0); // citam vr potenciometra
- int merenja[5]={0,0,0,0,0};
- merenja[x]=vrednost_potenciometra;
- int minimum=merenja[0]; // prvi je minimum
- int maks=merenja[0]; // drugi je maksimum
- for(int i=1;i<5;i++){
- if(merenja[i]>maks) maks=merenja[i];
- }
- Serial.println("Maks");
- Serial.println(maks);
- for(int i=1;i<5;i++){
- if(merenja[i]<minimum) minimum=merenja[i];
- }
- Serial.println("Minimum");
- Serial.println(minimum);
- if(200<(maks-minimum)) Serial.println("Doslo je do naglog skoka");
- else Serial.println("Nije doslo do naglog skoka");
- x=((x++)+1)%5;
- }
- void setup()
- {
- Serial.begin(9600);
- createTask(citanje,1000,TASK_ENABLE,NULL);
- }
- void loop()
- {
- }
Add Comment
Please, Sign In to add comment