3/26/16 12:25 am JJ
Dependents: steppertest R5 2016 Robotics Team 1
Fork of scanner by
Diff: scanner.cpp
- Revision:
- 18:f5c46fb2cd31
- Parent:
- 17:ec04d60f38bd
- Child:
- 19:795968997140
diff -r ec04d60f38bd -r f5c46fb2cd31 scanner.cpp --- a/scanner.cpp Wed Apr 06 22:05:34 2016 +0000 +++ b/scanner.cpp Thu Apr 07 21:09:17 2016 +0000 @@ -18,10 +18,10 @@ // Constructor. Scanner::Scanner(Serial &pc1, StepperDrive &_drive, PinName _servoL, PinName _servoR, ShortRangeSensor &_shortRangeL, ShortRangeSensor &_shortRangeR, LongRangeSensor &_longRangeL, - LongRangeSensor &_longRangeR, Gripper &_robotGrip, float _period) : pc(pc1), drive(_drive), servoL(_servoL), + LongRangeSensor &_longRangeR, Gripper &_robotGrip, float _period, ColorSensor &_colorSensor) : pc(pc1), drive(_drive), servoL(_servoL), servoR(_servoR), shortRangeL(_shortRangeL), shortRangeR(_shortRangeR), longRangeL(_longRangeL), - longRangeR(_longRangeR), robotGrip(_robotGrip), period(_period) + longRangeR(_longRangeR), robotGrip(_robotGrip), period(_period), colorSensor(_colorSensor) { servoL.period(1.0/50.0); servoR.period(1.0/50.0); @@ -234,13 +234,21 @@ myStack.push(moveRobot); } - // This is the code to enable the gripper to grip the peg. + // This code to enable the gripper to grip the peg. robotGrip.grip(); - /* pseudocode - implement the code for reading a value from the color sensor - store the value that is returned from the color sensor - */ + // This code is used to determine the color of the peg + // and the bool value will be used to control the + // navigation of the robot. + bool isPegColorRed; + + int colorValue; + colorValue = + + if(colorValue > 150) + isPegColorRed = true; + else + isPegColorRed = false; // This is the code to enable the gripper to lift the peg. robotGrip.lift();