Пример #1
0
void sabertooth(int m1, int m2)
	{
	//rprintfInit(uart2SendByte);//select uart2
	uartSetBaudRate(2, 38400);//select baud (see page 13/14 of datasheet)
	uart2SendByte(m1);//send a command for motor 1
	uart2SendByte(m2);//send a command for motor 2
	}
Пример #2
0
Файл: Axon.c Проект: abarbu/axon
void control(void)
{
  reset_timer5();
  uartFlushReceiveBuffer(1);

  a2dSetReference(ADC_REFERENCE_256V);
  delay_us(100);

  PORT_OFF(PORTB,7);

  while(1) {
    char read = uart1GetByte();
    if(read == 'U') { //Rangefinder only for the Hand! We only have 3 uart ports!
      uart0SendByte(0x22); //sends 4 bytes with the command to read distance (0x22)
      uart0SendByte(0x00); uart0SendByte(0x00);uart0SendByte(0x22);delay_us(50);
      uart0GetByte(); //we don't care about this byte
      rprintf("%d\r\n", 255*uart0GetByte() + uart0GetByte());
      uart0GetByte(); //we don't care about this byte
    } else if(read == 'L') {
      rprintf("%d\r\n", 255 - a2dConvert8bit(0));
    } else if(read == 'R') {
      rprintf("%d\r\n", 255 - a2dConvert8bit(1));
    } else if(read == 'D') {
      int buff='#';
      uart2SendByte('#'); uart2SendByte('o'); uart2SendByte('s');
      uart2SendByte('#'); uart2SendByte('f');
      delay_ms(60); // Do not change this delay or you'll get in trouble! 
      while(1) {
	buff = uart2GetByte();
	if(buff==10 || buff==13 || buff==-1) {
	  uart1SendByte('\r');
	  uart1SendByte('\n');
	  break;
	}
	uart1SendByte(buff);
      }
      while((buff=uart2GetByte()) != -1);
    }  else if(read == 'E') {
      int buff='#';
      uart3SendByte('#'); uart3SendByte('o'); uart3SendByte('s');
      uart3SendByte('#'); uart3SendByte('f');
      delay_ms(60); // Do not change this delay or you'll get in trouble! 
      while(1) {
	buff = uart3GetByte();
	if(buff==10 || buff==13 || buff==-1) {
	  uart1SendByte('\r');
	  uart1SendByte('\n');
	  break;
	}
	uart1SendByte(buff);
      }
      while((buff=uart3GetByte()) != -1);
    } else if(read == 'M') {
      int buff='#';
      uart2SendByte('#'); uart2SendByte('o'); uart2SendByte('t');
      uart2SendByte('#'); uart2SendByte('f');
      delay_ms(60); // Do not change this delay or you'll get in trouble! 
      while(1) {
	buff = uart2GetByte();
	if(buff==10 || buff==13 || buff==-1) {
	  uart1SendByte('\r');
	  uart1SendByte('\n');
	  break;
	}
	uart1SendByte(buff);
      }
      while((buff=uart2GetByte()) != -1);
    } else if(read == 'N') {
      int buff='#';
      uart3SendByte('#'); uart3SendByte('o'); uart3SendByte('t');
      uart3SendByte('#'); uart3SendByte('f');
      delay_ms(60); // Do not change this delay or you'll get in trouble! 
      while(1) {
	buff = uart3GetByte();
	if(buff==10 || buff==13 || buff==-1) {
	  uart1SendByte('\r');
	  uart1SendByte('\n');
	  break;
	}
	uart1SendByte(buff);
      }
      while((buff=uart3GetByte()) != -1);
    } else if(read == 'P') {
      PORT_ON(PORTB,6);
    } else if(read == 'p') {
      PORT_OFF(PORTB,6);
    } else if(read == 'Q') {
      PORT_ON(PORTB,7);
    } else if(read == 'q') {
      PORT_OFF(PORTB,7);
    } else if(read == 'X') {
      PORT_ON(PORTB,4);
    } else if(read == 'x') {
      PORT_OFF(PORTB,4);
    } else if(read == 'Y') {
      PORT_ON(PORTB,5);
    } else if(read == 'y') {
      PORT_OFF(PORTB,5);
    } 
    delay_us(50);
  }
}
Пример #3
0
void syren(int m1)
	{
	//rprintfInit(uart2SendByte);//select uart2
	uartSetBaudRate(2, 38400);//select baud (see page 14 of datasheet)
	uart2SendByte(m1);//send a command for motor 1
	}