diff options
-rw-r--r-- | Venus_Skeleton/Venus_Skeleton.ino | 38 |
1 files changed, 15 insertions, 23 deletions
diff --git a/Venus_Skeleton/Venus_Skeleton.ino b/Venus_Skeleton/Venus_Skeleton.ino index 99be3fb..1a38c3e 100644 --- a/Venus_Skeleton/Venus_Skeleton.ino +++ b/Venus_Skeleton/Venus_Skeleton.ino @@ -389,26 +389,21 @@ void sensSampleGripper() { // sensor IR, beacon detection and recognition int sensIRRemote() { - int x = 0; - int LabFound = LOW; - for (int i = 1; i <= 10; i++) - { - x = 0; - do - { - if(irrecv.decode(&results)) - { - irrecv.resume(); - } - x++; - if( x == 5 ) - { - LabFound = HIGH; - return LabFound; + int matches = 0; + for (int i = 0; i < 10; i++) { + if (irrecv.decode(&results)) { + // check for the parameters sent by IRbeacon.ino + if (results->decode_type == SONY && + results->bits == 12 && results->value != 0xa90) { + matches++; } - } while(results.value, DEC == LCode); + irrecv.resume(); + } } - return LabFound; + DEBUG_PRINT(matches); + DEBUG_PRINT(" IRRemote matches\n"); + // accept when half of the probes resulted in a match. + return matches >= 5; } void sensBeaconTurret() { @@ -416,12 +411,9 @@ void sensBeaconTurret() { // (creates triangle with centerOfRobot, centerOfSensor and Obstacle as its corners) if (timerTurret == 0) { - int i; - bool beacon = false; + bool beacon; - i = sensIRRemote(); // SENSORDATA HERE - if (i == HIGH) - beacon = true; + beacon = sensIRRemote(); // SENSORDATA HERE if (data.beacon_detected[counterTurret] != beacon) { data.beacon_detected[counterTurret] = beacon; |