Skip to content

Commit

Permalink
Merge pull request #92 from Lipotam/line_sensor_fix
Browse files Browse the repository at this point in the history
Line sensor fix
  • Loading branch information
AJIOB authored Mar 30, 2018
2 parents d2f073c + 5db9474 commit 93aab44
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 0 deletions.
1 change: 1 addition & 0 deletions code/Arduino/config/Constants.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ const uint8_t Constants::kDistanceSensorBPin = 5;
const uint8_t Constants::kDistanceSensorCPin = A3;

/* Line controller */
// A = 0, B = 1, C = 2
const uint8_t Constants::kLineSensorReadPin = A0;
const uint8_t Constants::kLineSensorAPin = 6;
const uint8_t Constants::kLineSensorBPin = 7;
Expand Down
41 changes: 41 additions & 0 deletions code/Arduino/peripheral/LineSensorManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ LineSensorManager::LineSensorManager()
}

void LineSensorManager::choose_sensor(int number) {
#if (LINE_SENSOR_REV == 1)

switch (number) {
case 1:
digitalWrite(Constants::kLineSensorAPin, LOW);
Expand Down Expand Up @@ -39,6 +41,45 @@ void LineSensorManager::choose_sensor(int number) {
default:
break;
}

#elif (LINE_SENSOR_REV == 2)

switch (number) {
case 1:
digitalWrite(Constants::kLineSensorAPin, LOW);
digitalWrite(Constants::kLineSensorBPin, LOW);
digitalWrite(Constants::kLineSensorCPin, HIGH);
break;
case 2:
digitalWrite(Constants::kLineSensorAPin, HIGH);
digitalWrite(Constants::kLineSensorBPin, LOW);
digitalWrite(Constants::kLineSensorCPin, HIGH);
break;
case 3:
digitalWrite(Constants::kLineSensorAPin, LOW);
digitalWrite(Constants::kLineSensorBPin, HIGH);
digitalWrite(Constants::kLineSensorCPin, HIGH);
break;
case 4:
digitalWrite(Constants::kLineSensorAPin, HIGH);
digitalWrite(Constants::kLineSensorBPin, HIGH);
digitalWrite(Constants::kLineSensorCPin, HIGH);
break;
case 5:
digitalWrite(Constants::kLineSensorAPin, HIGH);
digitalWrite(Constants::kLineSensorBPin, HIGH);
digitalWrite(Constants::kLineSensorCPin, LOW);
break;
default:
break;
}

delay(1);
#else

#error Line sensor revisions 1 or 2 are supported only

#endif
}

int LineSensorManager::get_sensor_value(int number) {
Expand Down
4 changes: 4 additions & 0 deletions code/Arduino/peripheral/LineSensorManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

#include "IBasicSensorManager.h"

// Line sensor board revision
// can be 1 or 2
#define LINE_SENSOR_REV 2

/**
* @brief Get information from line sensors. Line values are returned as @AreaType values
*/
Expand Down

0 comments on commit 93aab44

Please sign in to comment.