Yeongsoo Kim / Mbed 2 deprecated Mecha_Distance_Sensor

Dependencies:   mbed

Sensor/DistanceSensor.cpp

Committer:
yeongsookim
Date:
2020-11-12
Revision:
2:45082fedef80
Parent:
1:a9251be32d0a
Child:
3:511df198e214

File content as of revision 2:45082fedef80:

#include "DistanceSensor.h"

#define MAX_DISTANCE (-1.0)

DistanceSensor::DistanceSensor(PinName a): m_analogIn(a)
{
    m_distance = MAX_DISTANCE;
}

float DistanceSensor::getDistance_cm()
{
    float distance = 0.0;
    
    if (m_analogIn >= 3.0){
        distance = 5.0;
    }
    else if (m_analogIn < 3.0 && m_analogIn >= 2.5){
        distance = 10.0;
    }
    else if (/* Fill in the blank */){
        distance = /* Fill in the blank */;
    }
    else{
        distance = /* Fill in the blank */;
    }
    
    return distance;
}