示例#1
0
uint16_t DFRobot2WD::lireTelecommande(void)
/**
 * \brief renvoie le code de la touche envoyé par la télécommande infrarouge
 * \return 2 octets correspondant au code de la touche
 *	Cette fonction n'utilise pas le processus d'interruption
 *
 *	exemple:
 *				int codeIR = terminator.lireTelecommande();
 *				Serial.println(codeIR, HEX);
 */
{
    timer1_init();
    remote_decode();
    return ir_code;
}
示例#2
0
void main()
{
  uint8_t sw1,sw2,i;
  uint16_t k;
  int16_t backemf;
  int8_t d1,d2;
  uint8_t show[3] = {0,'f','b'};
  
  
  init_board();
  d1 = 0;
  d2 = 0;
  backemf =0;
  while (1)
  {
   sw1 = _7SEGMENT_SW1_IN_PORT & _7SEGMENT_SW1; 
   
   if (!sw1) // SW1  Press
    {   	
		d1++;
	     if (d1 > MOTOR_BACKWARD)
			d1 = MOTOR_STOP;
		for (k = 0; k < 500 ;k++)                         // Delay for key bounce
				delay(6000);						
		g_mode[0] = d1;
		g_angle[0] = 1;    // Continuous move

	}
   
   sw2 = _7SEGMENT_SW2_IN_PORT & _7SEGMENT_SW2; 
   if (!sw2) // SW2 Press
   {
        d2++;
		if (d2 > MOTOR_BACKWARD)
			d2 = MOTOR_STOP;
 		for (k = 0; k < 500 ;k++)                         // Delay for key bounce		
 				delay(6000);
		g_mode[1] = d2;
		g_angle[1] = 1;    // Continuous move	
   }

// Command decode
    if ( g_cmd_decode)
	{
// Decode command	
   	    cmd_decode (g_rcv_buff);
		g_cmd_decode = 0; 
//  		g_pos[g_motor] = 0;
  	}
	if(g_ircode)
	{
	   remote_decode (g_ircode);
	   g_ircode =0;
	}
 
    for (i = 0 ; i < MOTOR_MAX ; i++)
	{
// 7 Segments display	
		d7segment_display(show[g_mode[i]],i+1);
        delay(500);
 
    }
 
  }
  
}