Index: trunk/code/behaviors/formation_control/circle2/circle.c
===================================================================
--- trunk/code/behaviors/formation_control/circle2/circle.c	(revision 1567)
+++ trunk/code/behaviors/formation_control/circle2/circle.c	(revision 1568)
@@ -15,19 +15,19 @@
 	With adjustment, the leader robot will be able to turn and use its standardized
 	rangefinder to reposition or space the robots evenly.
 	
-	AuTHORS: Niko, Alex, Reva, Echo, Steve
+	AuTHORS: Nico, Alex, Reva, Echo, Steve
 */
 
 
 /* 
 TODO:
-	Check BOM more often and before final stop
-	Make BOM check more comprehensively
-	Use the center bot to check distances
+		Check BOM more often and before final stop
+		Make BOM check more comprehensively
+		Use the center bot to check distances
 		Count them ("spam" method)
 		Use beacon to find relative positions
 		Beacon tells them how to move to be at the right distance
-	Wireless communication, initialization
+		*done*Wireless communication, initialization
 */
 
 void forward(int speed){			// set the motors to this forward speed.
@@ -61,10 +61,11 @@
 		temp = range_read_distance(IR2);
 		if (temp == -1)
 		{
-			temp=0;
-			kk--;
+			//temp=0;
+			i--;
 		}
-		distance+= temp;
+		else
+			distance+= temp;
 		delay_ms(3);
 	}
 	if (kk>0)
@@ -143,9 +144,9 @@
 	for(int i = 0; i<num; i++)
 	{
 		orb_set_color(ORB_OFF);
-		delay_ms(200);
+		delay_ms(500);
 		orb_set_color(RED);
-		delay_ms(200);
+		delay_ms(500);
 	}
 	orb_set_color(ORB_OFF);
 }
@@ -161,7 +162,7 @@
 	/* Initialize the basic wireless library */
 	wl_basic_init_default();
 	/* Set the XBee channel to your assigned channel */
-	wl_set_channel(12);
+	wl_set_channel(24);
 
 	int robotid = get_robotid();
 	char send_buffer[2];
@@ -170,6 +171,9 @@
 	
 	
 	int state = EDGE;
+	int beacon_State=0;
+	int NUM_ROBOTS=2;
+	int robotsRecieved=0;
 	if(wheel()<100)
 	{
 		state=EDGE;
@@ -197,13 +201,21 @@
 						send_buffer[1]=get_robotid();
 						
 						wl_basic_send_global_packet(42,send_buffer,2);
+						break;
 					}
-					
-					if(packet_data != 0 && data_length>=2 && packet_data[0]==CIRCLE_ACTION_ACK)
+				}
+				
+				while(1){
+					orb_set_color(RED);
+					packet_data=wl_basic_do_default(&data_length);
+					wl_basic_send_global_packet(42,send_buffer,2);
+
+					if(packet_data != 0 && data_length>=2 && packet_data[0]==CIRCLE_ACTION_DONE)
 					{
 						break;
 					}
 				}
+				
 				orb_set_color(GREEN);
 				
 				orient();
@@ -215,6 +227,8 @@
 				distance = get_distance();
 				while (distance>=onefoot || distance==0)
 				{
+					if(distance==0)
+						orb_set_color(WHITE);
 					distance = get_distance();
 					orient2();
 					forward(speed);
@@ -230,32 +244,34 @@
 				
 				
 			case 1:			// BEACON
-				bom_on();
-				orb_set_color(PURPLE);
-				
-				int numrobots = 0;
-				
-				while(!button1_click())
-				{ }
-				
-				send_buffer[0]=CIRCLE_ACTION_EXIST;
-				send_buffer[1]=get_robotid();
-				
-				wl_basic_send_global_packet(42,send_buffer,2);
-				
+				switch(beacon_State) {
+				case 0:
+					bom_on();
+					orb_set_color(PURPLE);
+					if(button1_click()) beacon_State=1;
+				break;	
+				case 1:
+					send_buffer[0]=CIRCLE_ACTION_EXIST;
+					send_buffer[1]=get_robotid();
+					wl_basic_send_global_packet(42,send_buffer,2);
+					beacon_State=2;
+				break;
+				case 2: 
+				orb_set_color(ORANGE);
 				packet_data=wl_basic_do_default(&data_length);
-				while(packet_data != 0 && data_length>=2 && packet_data[0]==CIRCLE_ACTION_ACK)
+				if(packet_data!=0 && data_length>=2 && packet_data[0]==CIRCLE_ACTION_ACK)
 				{
-					// IF NEEDED: a good place to collect and store the robot id.
-					numrobots++;
+					orb_set_color(WHITE);
+					robotsRecieved++;
 				}
-				
-				send_buffer[0]=CIRCLE_ACTION_ACK;
+				if(robotsRecieved==NUM_ROBOTS)
+					beacon_State=3;
+				break;
+				case 3:
+				send_buffer[0]=CIRCLE_ACTION_DONE;
 				wl_basic_send_global_packet(42,send_buffer,2);
-				
-				blink(numrobots);
-				
-				
+				break;
+				}
 			break;
 		}
 	}
Index: trunk/code/behaviors/formation_control/circle2/circle.h
===================================================================
--- trunk/code/behaviors/formation_control/circle2/circle.h	(revision 1567)
+++ trunk/code/behaviors/formation_control/circle2/circle.h	(revision 1568)
@@ -14,6 +14,7 @@
 #define CIRCLE_ACTION_EXIST 'E'
 #define CIRCLE_ACTION_POSITION 'P'
 #define CIRCLE_ACTION_ACK 'A'
+#define CIRCLE_ACTION_DONE 'D'
 //#define EDGE 0;
 //#define BEACON 1;
 
Index: trunk/code/behaviors/formation_control/circle2/Makefile
===================================================================
--- trunk/code/behaviors/formation_control/circle2/Makefile	(revision 1567)
+++ trunk/code/behaviors/formation_control/circle2/Makefile	(revision 1568)
@@ -11,8 +11,7 @@
 USE_WIRELESS = 1
 
 # com1 = serial port. Use lpt1 to connect to parallel port.
-AVRDUDE_PORT = $(shell if uname -s |grep -i w32 >/dev/null; then echo 'COM4:'; else echo '/dev/ttyUSB0'; fi)
-
+AVRDUDE_PORT = $(shell if uname -s |grep -i w32 >/dev/null; then echo 'COM7:'; else echo '/dev/ttyUSB0'; fi)
 else
 COLONYROOT := ../$(COLONYROOT)
 endif
