Advertisement
barohayon

Eden_readTemp_v2

Jun 19th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # define TEMP_AVG_SIZE 10;
  2. float temp_avg_arr[TEMP_AVG_SIZE ] = {1};
  3. int temp_avg_ind=0;
  4.  
  5. float readTemp(){
  6.     int i;
  7.     float sum =0;
  8.     float new_temp = Tr; // TODO: update this line to read new temp!
  9.     temp_avg_arr[temp_avg_ind] = new_temp;
  10.     if(temp_avg_ind== 9){ // wrap around to start of array
  11.         temp_avg_ind=0;
  12.     }
  13.     else{
  14.         temp_avg_ind++;
  15.     }
  16.     for (i=0;i<TEMP_AVG_SIZE ;i++){
  17.         sum+=temp_avg_arr;
  18.     }
  19.    
  20.     float current_avg=sum/TEMP_AVG_SIZE;;
  21.     // TODO: use current_avg for whatever
  22.    
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement