-
Notifications
You must be signed in to change notification settings - Fork 0
IR_sensor
Alex Krieg edited this page Jun 13, 2018
·
4 revisions
- IR_sensor(byte IR_ledPin,byte IR_pdPin);
- ~IR_sensor();
- void update();
- byte ledPin();
- byte pdPin();
- void highTriggerValue(unsigned int triggerValue);
- unsigned int highTriggerValue();
- void lowTriggerValue(unsigned int triggerValue);
- unsigned int lowTriggerValue();
- void triggerHysteresis(unsigned int hysteresis);
- unsigned int triggerHysteresis();
- unsigned int value();
- void onLowTrigger(void (*p_func)());
- void onLowTrigger(void (*p_func)(),unsigned int triggerValue);
- void onHighTrigger(void (*p_func)());
- void onHighTrigger(void (*p_func)(),unsigned int triggerValue);
- void onBothTrigger(void (*p_func)());
- Constructor of the sensor
- Parameters are IR_ledPin and IR_pdPin
- IR_ledPin is the pin on which the IR-Led is connected to.
- IR_pdPin is the analog input on which the IR-photodiode is connected to.
IR_sensor mySensor(2,A0);
- Destructor
delete &mySensor;
- Reads the sensor value.
- Triggeres the events
mySensor.update();
- Gets the pin of the IR-led back.
byte pin = mySensor.ledPin();
- Gets the pin of the IR-photodiode back.
byte pin = mySensor.pdPin();
- Sets the trigger point for the onHighTrigger event.
mySensor.highTriggerValue(800);
- Gets the trigger point for the onHighTrigger event.
unsigned int triggPoint = mySensor.highTriggerValue();
- Sets the trigger point for the onLowTrigger event.
mySensor.lowTriggerValue(1000);
- Gets the trigger point for the onLowTrigger event.
unsigned int triggPoint = mySensor.lowTriggerValue();
- Sets the hysteresis for the events.
mySensor.triggerHysteresis(30);
- Gets the hysteresis for the events.
unsigned int hysteresis= mySensor.triggerHysteresis();
- Gets the current value of the IR-photodiode pin.
unsigned int value = mySensor.value();
You do not know how events work?
Look over here
- Is executed when the IR-light is no longer detected and the signal is above triggerValue.
- NO value accepted.
- NO return values.
- Is executed when the IR-light is detected and the signal is below triggerValue.
- NO value accepted.
- NO return values.
- Is executed when onLowTrigger or onHighTrigger is executed.
- NO value accepted.
- NO return values.
Wiki
Arduino libraries