public static void Main()
        {
#if SETID
            while (true)
            {
                /**
                 * First address gets bit-shifted so that the HERO uses the 7 bit address
                 * Second address is a parameter that gets passed so it must stay as an 8 bit address
                 */
                SonarModuleAddressChange what = new SonarModuleAddressChange(0x00 >> 1, 0xFE /* >> 1 */); //Front is 0xFE, Side is 0xE0 (This is the default for SRF08)
                Thread.Sleep(10);
            }
#else
            //Best settings found so far:
            //SRF10 -> Gains: 6, Range: 48
            //SRF08 -> Gains: 0, Range: 93
            MySonar.SetGain(6);        //SRF08 0-16, SRF10 0- 31
            MySonar.SetDistance(48);   //SRFXX 0 - 255
            uint SonarRead = 0;
            while (true)
            {
                MySonar.InitRanging(SonarModule.RangeType.Centimeters);
                SonarRead = MySonar.ReadRange();
                Debug.Print("Read: " + SonarRead);
            }
#endif
        }
示例#2
0
        public static void Main()
        {
#if SETID
            while (true)
            {
                SonarModuleAddressChange what = new SonarModuleAddressChange(0x00, 0xFE); //Front is 0xFE, Side is 0xE0 (This is the default for SRF08)
                Thread.Sleep(10);
            }
#else
            //Best settings found so far:
            //SRF10 -> Gains: 6, Range: 48
            //SRF08 -> Gains: 0, Range: 93
            MySonar.SetGain(6);        //SRF08 0-16, SRF10 0- 31
            MySonar.SetDistance(48);   //SRFXX 0 - 255
            uint SonarRead = 0;
            while (true)
            {
                MySonar.InitRanging(SonarModule.RangeType.Centimeters);
                SonarRead = MySonar.ReadRange();
                Debug.Print("Read: " + SonarRead);
            }
#endif
        }