Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- unsigned char n;
- const char depthPin = A0;
- using namespace std;
- void setup() {
- pinMode(depthPin, INPUT);
- }
- char medianFilter() {
- int depthArray[50];
- for(int a = 0; a != 50; a++) {
- depthArray[a] = analogRead(depthPin);
- }
- for(int i=0; i<n; ++i)
- for(int j=i+1; j<n; ++j)
- if(depthArray[j]<depthArray[i])swap(depthArray[i],depthArray[j]);
- return depthArray[24];
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement