Yeongsoo Kim / Mbed 2 deprecated Mecha_Distance_Sensor

Dependencies:   mbed

Sensor/DistanceSensor.cpp

Committer:
yeongsookim
Date:
2020-11-11
Revision:
0:64fe0ebc42c6
Child:
1:a9251be32d0a

File content as of revision 0:64fe0ebc42c6:

#include "DistanceSensor.h"

#define MAX_DISTANCE (-1.0)

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

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