public void headRand() { Random rand = new Random(); while (run) { int num = rand.Next(1000, 2000); int time = rand.Next(5, 7); Console.WriteLine("Sleeping" + num); Thread.Sleep(num); Console.WriteLine("Going left"); // servoShoulder.setTargetPosition(1200); // servoNeck.setTargetPosition(1400); //servos. Thread.Sleep(time * 1000); Console.WriteLine("Going right"); //servoShoulder.setTargetPosition(1700); //servoNeck.setTargetPosition(1500); servos.move(neck, 80); servos.move(head, 80); Thread.Sleep(time * 1000); //servoShoulder.setTargetPosition(1500); // servoNeck.setTargetPosition(1100); servos.move(neck, 30); servos.move(head, 30); Thread.Sleep(time * 1000); } }
private static void headRand() { Random rand = new Random(); while (run) { int neckpos = rand.Next(1100, 1500); int shopos = rand.Next(1200, 1700); //int time = rand.Next(3, 4); servoHandle.move(shoulder, Convert.ToUInt16(shopos)); servoHandle.move(neck, Convert.ToUInt16(neckpos)); Thread.Sleep(2000); while (detect) { Thread.Sleep(500); } } }