//-------------------------------------------------------------------------------
//Main Function
//-------------------------------------------------------------------------------
int main(void)
{
	init_devices();


	while(1)
	{
		sensor_data_interpretation();
		//print_sensor(1,1,1);				//Prints IR Proximity Sensor 1
		BATT_V = ADC_Conversion(0);
		BATT_Voltage = ((ADC_Conversion(0)*100)*0.07902) + 0.7;	//Prints Battery Voltage Status
		lcd_print(1,1,BATT_Voltage,4);

		//print_sensor(1,1,0);							//Prints Battery voltage binary value

		print_sensor(1,6,5);							//Prints IR Proximity Sensor 1
		print_sensor(1,10,6);							//Prints vlaue of Analog IR Proximity Sensor 2
		print_sensor(1,14,7);							//Prints value of Analog IR Proximity Sensor 3
		print_sensor(2,2,3);							//Prints value of White Line Sensor1
		print_sensor(2,6,2);							//Prints Value of White Line Sensor2
		print_sensor(2,10,1);							//Prints Value of White Line Sensor3

		//print_sensor(2,9,11); 						//Analog Value Of Front Sharp Sensor

		sharp = ADC_Conversion(11);						//Stores the Analog value of front sharp connected to ADC channel 11 into variable "sharp"
		value = Sharp_GP2D12_estimation(sharp);				//Stores Distance calsulated in a variable "value".
		lcd_print(2,14,value,3);
	}

}
示例#2
0
//-------------------------------------------------------****MAIN FUNCTION ****------------------------------------------------
int main()
{
	
	init_devices();
	lcd_set_4bit();
	lcd_init();
    lcd_cursor(1,1);
	lcd_string("START");
	_delay_ms(rand());
//--*** GRIPPER INITAL POSITION ***---
	S2 = 0x73;
	cli();
	timer0_init();
	TIMSK |= (1 << OCIE0) | (1 << TOIE0); // timer 0 compare match and overflow interrupt enable 
	sei();
	pickup();
	
	while(1)
	{
	if( bot_id_set == 1)
	{	
	
		init_devices2();
		init_grid();
		dispersion();
		localize();
		region_division();
		break;
	}
	
 }
 }
示例#3
0
//Main Function
int main()
{
	init_devices();
		
	while(1)
	{
	
		forward(); //both wheels forward
		_delay_ms(1000);
		
		back();
		_delay_ms(1000);
		

		/* stop();						
		_delay_ms(500);
	
		back(); //bpth wheels backward						
		_delay_ms(1000);

		stop();						
		_delay_ms(500);
		
		left(); //Left wheel backward, Right wheel forward
		_delay_ms(1000);
		
		stop();						
		_delay_ms(500);
		
		right(); //Left wheel forward, Right wheel backward
		_delay_ms(1000);

		stop();						
		_delay_ms(500);

		soft_left(); //Left wheel stationary, Right wheel forward
		_delay_ms(1000);
		
		stop();						
		_delay_ms(500);

		soft_right(); //Left wheel forward, Right wheel is stationary
		_delay_ms(1000);

		stop();						
		_delay_ms(500);

		soft_left_2(); //Left wheel backward, right wheel stationary
		_delay_ms(1000);

		stop();						
		_delay_ms(500);

		soft_right_2(); //Left wheel stationary, Right wheel backward
		_delay_ms(1000);

		stop();						
		_delay_ms(1000); */
	}
}
示例#4
0
/* Main routine */
void main(void)
{
    /* Initialize everything */

    init_port();   
    init_devices(); 
    init_adc();

    /* fading(); */
    /* adctest(); */
    
    /* Phase 1: use full power level */
    const_power(POWER_FULL, 1500, LED_ON, NO_DETECT_LV);
    
    /* Phase 2: transit from full level to holding level*/
    transit_power(POWER_FULL, POWER_HOLD, 1);
    
    /* Phase 3: Hold on holding level */
    if (const_power(POWER_HOLD, DEADLOOP, LED_BLINK, DETECT_LV) < 0)
    {
        /* Recommended steps: 
           const_power(POWER_ZERO); 
           delay(sometime, e.g.50ms);
           const_power(max); */
        const_power(POWER_HOLD, DEADLOOP, LED_OFF, NO_DETECT_LV);
    }
}
示例#5
0
int main()
{
	init_devices();
	init_nRF24L01();
	
		
	while(1)
	{	
		

		cnt2 ++;
		cnt2 %= 16;
		display_led( NUMTOSEG7( cnt2 ), 0xf1 );
		_delay_ms(500);
		Tx_Packet( message, 4 );
		_delay_ms(10);

		cnt = SPI_r_reg ( FIFO_STATUS );
		reg_d = cnt & 0xff00;
		reg_d >>= 8;	// STATUS
		display_led( NUMTOSEG7( reg_d ), 0xf2 );
		_delay_ms( 500 );
		
		reg_d = cnt & 0x00f0;	// reg high
		reg_d >>= 4;
		display_led( NUMTOSEG7( reg_d ), 0xf4 );
		_delay_ms( 500 );

		reg_d = cnt & 0x000f;	// reg low
		display_led( NUMTOSEG7( reg_d ), 0xf8 );
		_delay_ms( 500 );

	}
}
示例#6
0
int main()
{
	init_devices();
	lcd_set_4bit();
	lcd_init();
	color_sensor_scaling();/*
	threshold= calcThresh();
	setIndicatorAndColor();
	ct = 0; adj = 2;
	lcd("Begin");
	while (sorted<total)
	{
		canDrop();
		if (visitedCount == 3)
			predict();
		if (sorted == total)
			break;
		pickup();
		traverseToSort(ct, ct % 2 + 4);
		sortCheck();
	}
	for (i = 0; i<4; i++);
		//..printf("%d %d\n", term[i][0], term[i][1]);
	//..printf("Sort 0=%dSort 1=%d\nArm 0=%dArm 1=%d\n", sort[0], sort[1], arm[0], arm[1]);
	//..printf("Cost=%d\nSORTED!!!!!\n", cost + 7);
	//getch();
	*/
	
	forwardJaa();
	return 1;
}
//Main Function
int main()
{
    init_devices();
    lcd_set_4bit();
    lcd_init();
    while(1);
}
 void main(void)                     // Main Function
 {
	 init_devices();
	 int j=0;
	 while (1)
	 {

	 if(USART1_RX_vect() == 170)        // AA 1 st Sync data
	 {
		 if(USART1_RX_vect() == 170)      // AA 2 st Sync data
		 {
			 Plength = USART1_RX_vect();
			 if(Plength == 4)   // Small Packet
			 {

				 Small_Packet ();
			 }
			 else if(Plength == 32)   // Big Packet
			 {
				 Big_Packet ();
			 }
		 }
	 }
     }
}
示例#9
0
void
init_simple(void)
{
    screenInfo.numScreens = 1;
    screenInfo.screens[0] = &screen;

    screen.myNum = 0;
    screen.id = 100;
    screen.width = 640;
    screen.height = 480;
    screen.DeviceCursorInitialize = device_cursor_init;
    screen.DeviceCursorCleanup = device_cursor_cleanup;
    screen.SetCursorPosition = set_cursor_pos;
    screen.root = &root;

    dixResetPrivates();
    InitAtoms();
    XkbInitPrivates();
    dixRegisterPrivateKey(&XIClientPrivateKeyRec, PRIVATE_CLIENT,
                          sizeof(XIClientRec));
    dixRegisterPrivateKey(&miPointerScreenKeyRec, PRIVATE_SCREEN, 0);
    dixRegisterPrivateKey(&miPointerPrivKeyRec, PRIVATE_DEVICE, 0);
    XInputExtensionInit();

    init_window(&root, NULL, ROOT_WINDOW_ID);
    init_window(&window, &root, CLIENT_WINDOW_ID);

    serverClient = &server_client;
    InitClient(serverClient, 0, (void *) NULL);
    if (!InitClientResources(serverClient)) /* for root resources */
        FatalError("couldn't init server resources");
    SyncExtensionInit();

    devices = init_devices();
}
示例#10
0
void main(void)  
{
    init_devices();
    while(1)
    {
    }
}
示例#11
0
文件: main.c 项目: miselin/forgeos
void _kmain(struct multiboot_info *mboot) {
	clrscr();

	// This will make sure there's about 4K of space for malloc to use until physical
	// memory management is available for proper virtual memory.
	kprintf("Initialising malloc()...\n");
	dlmalloc_sbrk(0);

	kprintf("Initialising physical memory manager...\n");
	pmem_init(mboot);

	kprintf("Completing virtual memory initialisation...\n");
	vmem_init();

	kprintf("Configuring software and hardware interrupts...\n");
	interrupts_init();

	kprintf("Initialising machine devices...\n");
	init_devices();

	kprintf("Enabling interrupts...\n");
	interrupts_enable();

	kprintf("Startup complete!\n");

	while(1) __asm__ volatile("hlt");
}
//Main Function
int main(void)
{
 double error_p = 0.0;
 double error_i = 0.0;
 double error_d = 0.0;
 double angle;
 kalman_state k = kalman_init(1, 16, 1, 137);
 init_devices();
 lcd_set_4bit();
 lcd_init();
 double preverror = 0.0;
	 while(1)
	 {            
		sensor2 = ADC_Conversion(2);
        kalman_update(&k,(double)sensor2);
		angle = k.x;  
     	lcd_print(1,5,(int)angle,3);	 
		error_p = (angle - 137);
		error_i += error_p*dt;
		error_d = (error_p - preverror)/dt;
		lcd_print(1,1,abs((int)error_p),3);
		Disturbance = ((error_p*kp) + (error_i*ki) + (error_d*kd));
		if(angle > 137) back();
		else { 	forward();}
		if (Disturbance > MAX) Disturbance = MAX;
		if (Disturbance < MIN) Disturbance = MIN;
		lcd_print(2,6,abs((int)Disturbance),5);
		velocity(35+abs((int)Disturbance),35+abs((int)Disturbance));
		preverror = error_p;
	}
}
示例#13
0
/****************************** Main function ***************************/
void main()
{
 init_devices();
 rangoli_reset();
 rangoli();
//i = 0;

 while(1)
 {
	//botMove = 5;
	rangoli_I_IS_DRAW(ISDRAW);
    rangoli_I_MOTOR_SHAFT_LEFT(MOTOR_SHAFT_L);
    rangoli_I_MAX_ROW(MAXROW);
    rangoli_I_MAX_COLUMN(MAXCOLUMN);
    rangoli_I_GET_COLOR(GETCOLOR);
    rangoli_I_GET_LENGTH(GETLENGTH);
    rangoli_I_IS_FWD(ISFWD);
    rangoli_I_BOT_MOVE(BOTMOVE);
    rangoli_I_MOVEMENT_STATE(MOVEMENTSTATE);
    
		    
   // if (i==0) help();
	//	if(i == 1) help2();
	
    
    rangoli();
 }
}
示例#14
0
int
main(void)
{
	char	c;

	init_devices();

	comcninit();

	opt_subcmd_read(NULL);

	print_banner();

	c = awaitkey();
	if (c != '\r' && c != '\n' && c != '\0') {
		printf("type \"?\" or \"h\" for help.\n");
		bootmenu(); /* does not return */
	}

	command_boot(NULL);
	/*
	 * command_boot() returns only if it failed to boot.
	 * we enter to boot menu in this case.
	 */
	bootmenu();
	
	return 0;
}
示例#15
0
文件: test.c 项目: garthwebb/solarium
int main( int argc, char **argv ) {
	init_devices();

	int i, r, g, b;
	time_t start, end;
	double elapsed;

	while (1) {
		for (i=REG_PWM0; i<=REG_PWM15; i++) {
			for (r=0; r<=255; r+=10) {
//start = time((char *)0);
				for (g=0; g<=255; g+=10) {
					for (b=0; b<=255; b+=10) {
        					write_register(ADDR_BLUE, i, b);
					}
        				write_register(ADDR_GREEN, i, g);
				}
				write_register(ADDR_RED, i, r);
//end = time((char *)0);
//elapsed = (end - start);
//printf("Elapsed %f : %5.2f K/s\n", elapsed, (191.25/elapsed));

			}
			write_register(ADDR_RED, i, 0);
			write_register(ADDR_GREEN, i, 0);
			write_register(ADDR_BLUE, i, 0);
		}
	}

	cleanup();
}
int main(void)
{
	init_devices();
	lcd_set_4bit();
	lcd_init();
	lcd_cursor(1,5);
	lcd_string("HI");
	lcd_print(2,1,read,3);
	while(1)
	{ 
		//white line sensing
	    sensor_data_interpretation();

		flag=0;
		

		if(Center_white_line<0x28)
		{
			flag=1;
			forward();
			velocity(150,150);
		}

		if((Left_white_line>0x28) && (flag==0))
		{
			flag=1;
			forward();
			velocity(130,50);
		}

		if((Right_white_line>0x28) && (flag==0))
		{
			flag=1;
			forward();
			velocity(50,130);
		}

		if(Center_white_line>0x28 && Left_white_line>0x28 && Right_white_line>0x28)
		{
			forward();
			velocity(0,0);
		}
		if(count>=6)
		 break;
	}
	stop();
	read = 0;
	lcd_init();
	//Printing the stored value on lcd after the count value is reached 6.
	lcd_print(1,1 , store[0][0], 3);
	lcd_print(1,5 , store[0][1], 3);
	lcd_print(1,9 , store[0][2], 3);
	lcd_print(1,13 , store[0][3], 3);
	lcd_print(2,1 , store[0][4], 3);
	lcd_print(2,5 , store[0][5], 3);
	while(1);
	 
	
}
//Main Function
int main(void)
{
	init_devices();
	USART_Transmit('+');
	USART_Transmit('+');
	USART_Transmit('+');
	
	while(1);
}
//Main Function
int main()
{
	init_devices();
	velocity (100, 100); //Set robot velocity here. Smaller the value lesser will be the velocity
						 //Try different valuse between 0 to 255
	while(1)
	{
	
		forward(); //both wheels forward
		_delay_ms(1000);

		stop();						
		_delay_ms(500);
	
		back(); //both wheels backward						
		_delay_ms(1000);

		stop();						
		_delay_ms(500);
		
		left(); //Left wheel backward, Right wheel forward
		_delay_ms(1000);
		
		stop();						
		_delay_ms(500);
		
		right(); //Left wheel forward, Right wheel backward
		_delay_ms(1000);

		stop();						
		_delay_ms(500);

		soft_left(); //Left wheel stationary, Right wheel forward
		_delay_ms(1000);
		
		stop();						
		_delay_ms(500);

		soft_right(); //Left wheel forward, Right wheel is stationary
		_delay_ms(1000);

		stop();						
		_delay_ms(500);

		soft_left_2(); //Left wheel backward, right wheel stationary
		_delay_ms(1000);

		stop();						
		_delay_ms(500);

		soft_right_2(); //Left wheel stationary, Right wheel backward
		_delay_ms(1000);

		stop();						
		_delay_ms(1000);
	}
}
//Main Function
int main(void)
{
	init_devices();
	lcd_init();
	lcd_set_4bit();
	while(1){
		detect();
	}
}
示例#20
0
link_phy_t link_phy_open(const char * name, int baudrate){
	link_phy_t fd;
	uint32_t pinmask;

#ifdef __PHY_USB
	fd = link_phy_usb_open();
	if( fd <  0){
		led_error();
		return -1;
	}

#else
	uart_attr_t attr;

	fd = open("/dev/uart0", O_RDWR);
	if( fd <  0){
		return -1;
	}

	attr.baudrate = 460800;
	attr.parity = UART_PARITY_EVEN;
	attr.pin_assign = 0;
	attr.start = UART_ATTR_START_BITS_1;
	attr.stop = UART_ATTR_STOP_BITS_2;
	attr.width = 8;
	if( ioctl(fd, I_UART_SETATTR, &attr) < 0 ){
		return -1;
	}

#endif

	pinmask = (1<<18);
	hwpl_core_privcall(led_priv_on, &pinmask);
	usleep(50*1000);
	hwpl_core_privcall(led_priv_off, &pinmask);
	pinmask = (1<<20);
	hwpl_core_privcall(led_priv_on, &pinmask);
	usleep(75*1000);
	hwpl_core_privcall(led_priv_off, &pinmask);
	pinmask = (1<<21);
	hwpl_core_privcall(led_priv_on, &pinmask);
	usleep(100*1000);
	hwpl_core_privcall(led_priv_off, &pinmask);
	pinmask = (1<<23);
	hwpl_core_privcall(led_priv_on, &pinmask);
	usleep(200*1000);
	hwpl_core_privcall(led_priv_off, &pinmask);

	link_phy_flush(fd);

#ifdef XIVELY
	init_devices();
#endif

	return fd;
}
int main()
{

    cli();
    //unsigned char csr = MCUCSR;
    MCUCSR = 0;

#if USE_WDOG
    wdt_disable();
#endif

    init_devices();
    flash_led2_once();

    lcd_clear();
    lcd_gotoxy( 0, 0 );
    lcd_puts("Load EEPROM:");
    lcd_gotoxy( 0, 1 );

    load_eeprom_settings();
    flash_led1_once();

#if USE_WDOG
    wdt_enable(WDTO_2S);
#endif

    for (;;)
    {
        modbus_process_rx();
#if 1
        menu_run();
#else
        lcd_gotoxy( 0, 0 );

        int i;

        i = adc_value[6] >> 5;
        lcd_puts("vr1=");
        lcd_puti(i);
        i = adc_value[7] >> 5;
        lcd_puts(" vr2=");
        lcd_puti(i);
        lcd_puts("  ");
#endif

#if USE_WDOG
        wdt_reset();
#endif
    }


    while(1)
        ; // die here

    return 1;
}
示例#22
0
        platform& operator=(cl_platform_id id)
        {
            if(id_ != id)
            {
                id_ = id;
                devices = init_devices(id);
            }

            return *this;
        }
示例#23
0
int main()
{
	int i=0;
	init_devices();
	lcd_set_4bit();
	lcd_init();
	color_sensor_scaling();
	/*
	//variable 'i' scales at 13,14 for sharp sensor for velocitty 240 240
	//u turn 1600ms at 200,200 velocity
	velocity(200,200);
	left();
	_delay_ms(1600);
	stop();
	while(1);
	
	threshold=6000;
	
	right();
	while(ADC_Conversion(11)<65)
	{
		i++;
		lcd_print(1,11,i,3);
	}
	stop();
	lcd_print(2,11,scan(),1);
	stop();
	while(1);
	*/
	setIndicatorAndColor();
	threshold=6000;
	ct = 0; adj = 2;
	//lcd("Begin");
	while (sorted<total)
	{
		canDrop();
		//buzzer_on();
		//_delay_ms(500);
		//buzzer_off();
		if (visitedCount == 3)
			predict();
		if (sorted == total)
			break;
		pickup();
		traverseToSort(ct, ct % 2 + 4);
		sortCheck();
	}
	for (i = 0; i<4; i++);
		//..printf("%d %d\n", term[i][0], term[i][1]);
	//..printf("Sort 0=%dSort 1=%d\nArm 0=%dArm 1=%d\n", sort[0], sort[1], arm[0], arm[1]);
	//..printf("Cost=%d\nSORTED!!!!!\n", cost + 7);
	//getch();
	return 0;
}
/****************************** Main function ***************************/
void main()
{
 init_devices();
 Obstacle_Avoidance_reset();
 Obstacle_Avoidance();
 while(1)
 {
  Obstacle_Avoidance_I_KINECT(GESTURE_VALUE);
    Obstacle_Avoidance();
 }
}
示例#25
0
int main() {

	init_devices();
	while(1){
		forward_mm(50);
		back_mm(50);
		left_degrees(90);
		right_degrees(90);
	}

 return 0;
}
示例#26
0
文件: test1.c 项目: Devj92/test1
//-------------------------------------------------------------------------------
// Main Programme start here.
//-------------------------------------------------------------------------------
int main(void)
{   
 uint16_t x_byte = 0,y_byte = 0,z_byte = 0;
  uint8_t x_byte1 = 0,x_byte2 = 0,y_byte1 = 0,y_byte2 = 0,z_byte1 = 0,z_byte2 = 0;

 init_devices();
 lcd_set_4bit();                // set the LCD in 4 bit mode
 lcd_init();                    // initialize the LCD with its commands
 display_clear();               // clear the LCD
 write_byte(0x0,0x2D);
 write_byte(0x8,0x2D);

 
while(1)
{
	   
	   
	  x_byte1 = read_byte(X1);
	   //lcd_print(1,1,x_byte1,3);
	   
	   x_byte2 = read_byte(X2);
	   //lcd_print(2,1,x_byte2,3);
	   
	   y_byte1 = read_byte(Y1);
	   //lcd_print(1,6,y_byte1,3);
	   
	   y_byte2 = read_byte(Y2);
	   //lcd_print(2,6,y_byte2,3);
	   
	   z_byte1 = read_byte(Z1);
	   //lcd_print(1,10,z_byte1,3);
	   
	   z_byte2 = read_byte(Z2);
	   //lcd_print(2,10,z_byte2,3);
	   //_delay_ms(100);
	   
	   x_byte = x_byte2;
	   x_byte = x_byte<<8;
	   x_byte |= x_byte1;
	   pr_int(1,1,x_byte,3);
	   
	   y_byte = y_byte2;
	   y_byte = y_byte<<8;
	   y_byte |= y_byte1;
	   pr_int(2,4,y_byte,3);
	   
	   z_byte = z_byte2;
	   z_byte = z_byte<<8;
	   z_byte |= z_byte1;
	   pr_int(1,9,z_byte,3);
	 	   
}
}
//main function
int main(void)
{   
	init_devices();
	while(1)
	{
		if(count==10)
		{
			break;
		}
	}
   
}
示例#28
0
int main() {

	init_devices();
	reset_servo();
	// bot will start when user press 8 from numberpad in xbee consule in xctu
	while(1) {
		if (simulated) {
			simulate();
			break;
		}
	}
}
示例#29
0
int main(void){
  WDTCTL = WDTPW + WDTHOLD;                 // Stop WDT
  init_devices();
  while(1){ 
    asm("NOP");
    
    RF_Connection_Test2();
    //RF_Connection_Test();
    asm("NOP");
  }
  
}
//Main function
int main(void)
{
	//Initialize value array with 0
	int i;
	for(i=0;i<1000;i++){
		val_array[i] = 0;
	}
	
	data_pos = 0;
	bot_pos = 0;
	
	init_devices();

	//LCD_Reset_4bit();
	lcd_cursor(2,1);
	lcd_string("DRAWOID");
	
	while(1){
		if (bot_pos < data_pos){
			lcd_print(1,9,val_array[bot_pos],3);
			lcd_cursor(1,1);
			if (mov_array[bot_pos] == 'F'){
				lcd_string("F");
				move_straight(val_array[bot_pos],1);
			}
			else if (mov_array[bot_pos] == 'B'){
				lcd_string("B");
				move_straight(val_array[bot_pos],0);
			}
			else if (mov_array[bot_pos] == 'R'){
				lcd_string("R");
				turn_right(val_array[bot_pos]);
			}
			else if (mov_array[bot_pos] == 'L'){
				lcd_string("L");
				turn_left(val_array[bot_pos]);
			}
			else if (mov_array[bot_pos] == 'U'){
				lcd_string("U");
				pen_up();
			}
			else if (mov_array[bot_pos] == 'D'){
				lcd_string("D");
				pen_down();
			}
			bot_pos++;
			_delay_ms(1000);
		}
	}

	return 0;
}