Main Site Documentation

Robot Driving Logic Needed


Hello Experts,

Anyone know of good code to drive the mini robot with say… couple distance sensors? I can crack my head and try to “re-invent the wheel”… come up with the logic for it but It will make me loose more hair, and I bet it will still be buggy.

Thank You!


Always use baby steps…first, were you able to more the robot? rotate? go backwards?



I am able to move robot, read signal from reflective sensor and act acordingly like backing up, etc.

using System;
using Microsoft.SPOT;
using System.Threading;
using GHIElectronics.NETMF.FEZ;
namespace FEZ_Mini_DEMO

    public class Program
        static FEZ_Components.DistanceDetector myRanger = new FEZ_Components.DistanceDetector(FEZ_Pin.AnalogIn.An1,  FEZ_Components.DistanceDetector.SharpSensorType.GP2D120);
        static FEZ_Components.ReflectiveSensor InputPortA6 = new FEZ_Components.ReflectiveSensor(FEZ_Pin.AnalogIn.An6, 10);
        static FEZ_Components.ReflectiveSensor InputPortA7 = new FEZ_Components.ReflectiveSensor(FEZ_Pin.AnalogIn.An7, 10);
        static FEZ_Components.ServoMotor myServo = new FEZ_Components.ServoMotor(FEZ_Pin.Digital.Di8);

        public static void Main()
            FEZ_Components.LED OnBoardLED = new FEZ_Components.LED(FEZ_Pin.Digital.LED);
            OnBoardLED.StartBlinking(100, 500);
            for (int i = 1000; i < 10000; i += 100)
                FEZMini_Robot.Beep(i, 10); 

            while (true){
               if ((byte)InputPortA6.GetState()==1 || (byte)InputPortA7.GetState()==1)
                    FEZMini_Robot.MoveRamp(-40, -40, 0);//backing up a little
                    FEZMini_Robot.MoveRamp(-60, 10, 0); //turn around
                    FEZMini_Robot.MoveRamp(0, 0, 0);

                    FEZMini_Robot.Beep(6000, 300); //make some noise 
                    FEZMini_Robot.Beep(6000, 300);
                    FEZMini_Robot.Beep(6000, 300);
                    FEZMini_Robot.MoveRamp(50, 50, 0); //Left +, Right +