---
# System prepended metadata

title: "\nclass sensor\n"

---

<h1>
class sensor
</h1>

``` arduino=
class sensor
{
  const int analogPin;
  const int digitalPin;

public:
  sensor();
  bool detectSomething();
};

sensor::sensor(int d =-8, int a =-8)
  :digitalPin(d), analogPin(a)
{
  if(digitalPin > 0)
    pinMode(digitalPin, INPUT);

  if(analogPin > 0)
    pinMode(digitalPin, INPUT);
}

sensor::bool detectSomething()
{
  return(digitalRead(digitalPin));
}
```