Ejemplo n.º 1
0
/* Habilita los sensores segun corresponda para comenzar la lectura*/
void startReading(int sensors)
{
	// Sensor1
	if (bit_test(sensors, 0) == 1)
		sensor1 = SENSOR_ON;

	// Sensor2
	if (bit_test(sensors, 1) == 1)
		sensor2 = SENSOR_ON;

	// Sensor3
	if (bit_test(sensors, 2) == 1)
		sensor3 = SENSOR_ON;

	// Sensor4
	if (bit_test(sensors, 3) == 1)
		sensor4 = SENSOR_ON;

	// Sensor5
	if (bit_test(sensors, 4) == 1)
		sensor5 = SENSOR_ON;

	// Sensor6
#if TRIGGER_TYPE == ULTRASONIC_SENSOR
	// Sensor6 -> ULTRASONIC_SENSOR
	if (bit_test(sensors, 5) == 1)
	{
		// Comienza el pulso de habilitacion -> TRIGGER como escritura
		bit_clear(trisB_value, 0);
		set_tris_b(trisB_value);
		// Pin en estado habilitado -> envio del pulso INIT
		trigger = 1;
		delay_us(ULTRASONIC_INIT_PULSE_WIDTH_US);
		trigger = 0;
		// Termina el pulso de habilitacion -> TRIGGER como lectura
		bit_set(trisB_value, 0);
		set_tris_b(trisB_value);
		// Setea la interrupcion sobre RB0 en flanco ascendente
		ext_int_edge(L_TO_H);
		// Seteo el estado actual del pulso del sensor de ultrasonido
		usonic_state = USONIC_STATE_START;
		// Habilita la interrupcion
		enable_interrupts(INT_EXT);
	}
#elif TRIGGER_TYPE == SWITCH_SENSOR
	// Sensor6 -> SWITCH_SENSOR
	if (bit_test(sensors, 5) == 1)
	{
		if (trigger == 1)
			values[5] = 0xFFFF;
		else
			values[5] = 0;		
	} 
#endif

	return;
}	
void main()
{

   setup_adc_ports(NO_ANALOGS|VSS_VDD);
   setup_adc(ADC_OFF|ADC_TAD_MUL_0);
   setup_psp(PSP_DISABLED);
   setup_spi(SPI_SS_DISABLED);
   setup_wdt(WDT_OFF);
   setup_timer_0(RTCC_INTERNAL|RTCC_DIV_16|RTCC_8_bit);
   setup_timer_1(T1_DISABLED);
   setup_timer_2(T2_DISABLED,0,1);
   setup_comparator(NC_NC_NC_NC);
   setup_vref(FALSE);
   enable_interrupts(INT_RTCC);
   enable_interrupts(INT_EXT);
   enable_interrupts(INT_EXT1);
   enable_interrupts(GLOBAL);
   
   set_tris_a (0b11110000);
   set_tris_b (0b00000000);
   set_tris_c (0b00000000);
   
   cubeLevelC0 = 0xFF;
   cubeLevelC1 = 0x00;
   cubeLevelC2 = 0xFF;
   cubeLevelC3 = 0x00;
   
   cubeLevelD0 = 0x00;
   cubeLevelD1 = 0xFF;
   cubeLevelD2 = 0x00;
   cubeLevelD3 = 0xFF;

}
Ejemplo n.º 3
0
//                        ** Grundinitialisierung **
void coldstart () 
{   
    setup_adc_ports(sAN0|sAN1|sAN2|sAN3|sAN4|VSS_VDD);
   setup_adc(ADC_CLOCK_INTERNAL|ADC_TAD_MUL_0);
   setup_oscillator(OSC_8MHZ|OSC_INTRC);
   setup_comparator(NC_NC_NC_NC);
   output_a (0b00001000);
   output_b (0);
   output_c (0);
   output_d (0);
   output_e (0);
   set_tris_a (TRISA_INIT);               // Datenrichtung Port A
   set_tris_b (TRISB_INIT);               // Datenrichtung Port B
   set_tris_c (TRISC_INIT);
   set_tris_d (TRISD_INIT);
   set_tris_e (TRISE_INIT);
   port_b_pullups(TRUE);
    setup_timer_0(RTCC_INTERNAL|RTCC_DIV_32|RTCC_8_BIT);
                                    // Timer0 intern, Takt 20.00/4/64 = 78.125 KHz
                                       // Interrupt alle 256/15.625 = 3.2768 ms (305Hz)
                                       // Korrekturwert für 10 ms: 156 Timerclicks
                                       // -> Timer wird auf 256-156=100 vorgestellt 
      set_timer0 (Timerstartwert_K);            // Timerwert auf Startwert setzen
      enable_interrupts(INT_TIMER0);
   setup_timer_1(T1_DISABLED);               // Nur Timer0 Interrupt
   delay_ms (200);
}            
Ejemplo n.º 4
0
//=============================================================================
void init_prog(void)
{
setup_wdt(WDT_OFF);
setup_adc_ports(NO_ANALOGS|VSS_VDD);
setup_adc(ADC_OFF);
setup_psp(PSP_DISABLED);                                                
setup_spi(SPI_SS_DISABLED);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_16|RTCC_8_BIT);// TIMER0
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_timer_3(T3_DISABLED|T3_DIV_BY_1);
setup_comparator(NC_NC_NC_NC);                                           
setup_vref(FALSE);
setup_low_volt_detect(FALSE);              
setup_oscillator(OSC_32MHZ);                                        

set_tris_a(0xFF);//7F
set_tris_b(0xFF); //FF
set_tris_c(0x94);//94
set_tris_d(0xFF); //02                                     
set_tris_e(0xF0);  //f0   
set_tris_f(0xFF);//ff
set_tris_g(0xFC); //04
output_a(0x00);
output_b(0x00);
output_c(0x00);
output_d(0x00);
output_e(0x00);
output_f(0x00);
output_g(0x00);
}
Ejemplo n.º 5
0
byte lcd_read_byte() {
      byte low,high;

      set_tris_b(LCD_READ);
      lcd.rw = 1;
      delay_cycles(1);
      lcd.enable = 1;
      delay_cycles(1);
      high = lcd.data;
      lcd.enable = 0;
      delay_cycles(1);
      lcd.enable = 1;
      delay_us(1);
      low = lcd.data;
      lcd.enable = 0;
      set_tris_b(LCD_WRITE);
      return( (high<<4) | low);
}
Ejemplo n.º 6
0
void init()
{
	// Inicializa puertos
	set_tris_a(0b11100101);
	set_tris_b(0b11100110);

	// Variable para hacer el reset
	reset = false;

	return;	
}	
Ejemplo n.º 7
0
/*======================= configuracon de dispositivos =======================*/
void setup_devices(){
	//int myerror = 0;
   /*========================= configuracion del USB =========================*/
   myerror = COM_init();
   /*========================= configuracion del MMA7455 =====================*/
   //myerror += MEMORIA_init_hw();
   //myerror += MEMORIA_init();
   
   /*========================= conversor analogo/digital =====================*/
   // myerror = AD_init_adc();
   
   /*========================= modulo CPP ====================================*/
   //myerror = CP_init_ccp();
   
   /*========================= configuracion del Reloj Digital ===============*/
   //ds1307_init(DS1307_OUT_ON_DISABLED_HIHG | DS1307_OUT_ENABLED | DS1307_OUT_1_HZ);
   //ds1307_set_date_time(0x0d, 0x01, 0x0d, 0x00, 0x0a, 0x2a, 0x00);
   
   
   
   /*-------------------------------------------------------------------------*/
   setup_psp(PSP_DISABLED);
   setup_wdt(WDT_OFF);
   setup_timer_0(RTCC_INTERNAL);
   setup_timer_1(T1_DISABLED);
   setup_timer_2(T2_DISABLED,0,1);
   setup_comparator(NC_NC_NC_NC);
   setup_vref(FALSE);
   
   #ifndef CAPTURA_FRECUENCIA_H
	setup_timer_3(T3_DISABLED|T3_DIV_BY_1);
	setup_ccp1(CCP_OFF);
   #endif
   
   /*-------------------------------------------------------------------------*/
   
   /*===================para los indicadores========================*/
   set_tris_e(0x00);
   set_tris_b(0x00);
   set_tris_c(0x80);		//configuracion para el modulo de memoria
   set_tris_d(0x48);
   output_bit(INDICADOR_USB, 0);
   output_bit(INDICADOR_AMARILLO, 1);
   ////////////////////////////////
   output_low(SPI_SCL);
   output_high(SPI_SS);
   output_low(SPI_MOSI);
   output_high(SPI_MISO);
   ////////////////////////////////
   //delay_ms(3000);
   /*===============================================================*/
   return;
}
Ejemplo n.º 8
0
void init_device ()
{
    set_tris_a (0x18);          /* 0b11000 */
    set_tris_b (0);

    output_b (0);
    output_a (0);

    out_of_game = 1;

    output_high (LED_OUT);
}
Ejemplo n.º 9
0
void drive_stepper(BYTE speed, char dir, BYTE steps) {
   static BYTE stepper_state = 0;
   BYTE i;

   for(i=0; i<steps; ++i) {
      delay_ms(speed);
      set_tris_b(0x0f);
      port_b = POSITIONS[ stepper_state ] << 4;
      if(dir!='B')
         stepper_state=(stepper_state+1)&(sizeof(POSITIONS)-1);
      else
         stepper_state=(stepper_state-1)&(sizeof(POSITIONS)-1);
   }
}
void main(){
  set_tris_a(0x01);
  set_tris_b(0x00);
  setup_adc(adc_clock_internal);
  setup_adc_ports(AN0);
  Servo_init(48); //Coloca a +-90° los servos declarados

  while(true){
    set_adc_channel(0); //RA0 sensor del dedo pulgar
    delay_us(20);
    sensor_pulgar = getc_adc();
    sensor_pulgar = map(sensor_pulgar, 511, 1023, 0, 180);
    Servo_PWM(SERVO_DEDO_PULGAR, sensor_pulgar);
  }
}
Ejemplo n.º 11
0
void lcd_init() {
    byte i;

    set_tris_b(LCD_WRITE);
    lcd.rs = 0;
    lcd.rw = 0;
    lcd.enable = 0;
    delay_ms(15);
    for(i=1;i<=3;++i) {
       lcd_send_nibble(3);
       delay_ms(5);
    }
    lcd_send_nibble(2);
    for(i=0;i<=3;++i)
       lcd_send_byte(0,LCD_INIT_STRING[i]);
}
Ejemplo n.º 12
0
void main(void)
{
   int i;

   set_tris_b(0x10000000);
   
   output_high(PIN_B0);
   delay_ms(500);
   output_low(PIN_B0);
   
   fprintf(A, "rs232 init...\n\r");
   
   usb_init_cs();

   while(1)
   {
      if(input(PIN_B7))
      {
         output_high(PIN_B0);

         usb_task();

         while(input(PIN_B7))
         {
            if (usb_enumerated())
            {
               if (usb_kbhit(1))
               {
                  receive_msg();
                  //usb_get_packet(1, rdata, 1);
               
                  //fprintf(A, "%u", rdata[0]);
                  //switch(rdata[0])
                  //{
                  //   case 0x01: output_high(PIN_B0); break;
                  //   case 0x02: output_low(PIN_B0); break;
                  //}
               }
            }
         }
      
         usb_detach();
         
         output_low(PIN_B0);
      }
   }
}
Ejemplo n.º 13
0
void main()
{
    unsigned int8 t;

    //set_tris_a(0b00000000);
    set_tris_b(0b00010000);

    printf("foi: ");

    t = read_eeprom(0);
    printf("%u", t);

    //while(1)
    //{
//      printf("rain");
//   }
}
Ejemplo n.º 14
0
//PROGRAMA PRINCIPAL
void main ()
{
   int8 DisNumbs[10] = {   //Este arreglo guarda los códigos para la representación de los números en el display.
      0b00111111, //0
      0b00000110, //1
      0b01011011, //2
      0b01001111, //3
      0b01100110, //4
      0b01101101, //5
      0b01111101, //6
      0b00000111, //7
      0b01111111, //8
      0b01101111  //9
   };
//Parámetros de Timer0.
   setup_timer_0(RTCC_INTERNAL|RTCC_DIV_16);
//Habilitación de interrupciones.
   enable_interrupts(INT_RTCC);
   enable_interrupts(GLOBAL);
//Parámetros del ADC.
   setup_adc_ports(RA0_ANALOG);
   setup_adc(ADC_CLOCK_INTERNAL);
   set_adc_channel(0);
   delay_us(10);   //Se requiere un pequeño delay para estabilizar la señal al cambiar de canal.
//Puertos usados para displays en salida.
   set_tris_b(0x00);
   set_tris_c(0x00);
   set_tris_d(0x00);
   output_b(0x00);
   output_c(0x00);
   output_d(0x00);

   while (true) {
   //Se le da salida a los números calculados de acuerdo al display al que están conectados.
      if (readSens){
         readSens=false;
         ValAnalog = read_adc();   //Se lee y convierte el valor analógico a digital.
         Temperatura = (float)ValAnalog * (0.48875);   //Se convierte el valor digital a ºC
         Calcs();
      }
      output_b(DisNumbs[Decena]);
      output_c(DisNumbs[Unidad]);
      output_d(DisNumbs[Decimal]);
   }
}
Ejemplo n.º 15
0
void main() {
  char pos1,pos2;

  set_tris_b(0);
  port_b=0;

  pos1='0';
  pos2='1';

  while(TRUE) {
    display(pos1,pos2);
    if(kbhit()) {
       pos1=pos2;
       pos2=getc();
    }
  }

}
Ejemplo n.º 16
0
// Frequency of interrupt (clock/(4*divisor)) / (256-reload) 
void mcu_init() 
{ 
   setup_oscillator(OSC_16MHZ); 
   setup_adc_ports(NO_ANALOGS); 
   setup_adc(ADC_OFF); 
   setup_comparator(NC_NC_NC_NC); 

 
   // Setup the TIMER0 Interrupt 
   set_timer0(0); 
   setup_timer_0(RTCC_INTERNAL | RTCC_8_BIT | RTCC_DIV_4); 
   enable_interrupts(INT_TIMER0); 
   enable_interrupts(GLOBAL); 

   set_tris_a(0);
   set_tris_b(0);
   set_tris_c(0);
}
Ejemplo n.º 17
0
void main()
{
                                                                                                                                                                                 
setup_psp(PSP_DISABLED);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_adc_ports(NO_ANALOGS);
setup_adc(ADC_OFF);
setup_CCP1(CCP_OFF);
setup_CCP2(CCP_OFF);

set_tris_b(0x00);
set_tris_d(0b00000001);
set_tris_a(0x00);


output_b(0x00);


   start:
    if (input(pin_a0)==true)
    { 
    while(1==1){
      for(a=pin_b0; a<=pin_b5; a++)
      {
         output_high(a);
         delay_ms(100);
         output_low(a);
      
      }
      for( b=a; b>=pin_b0; b--)
      {
         output_high(b);
         delay_ms(100);
         output_low(b);
       
      }
 
    }
    a=0;
    b=0;
    }
     goto start;             
}
Ejemplo n.º 18
0
void main( void )
{
  
    setup_adc_ports( NO_ANALOGS );
	set_tris_a(0b00000000 );
    set_tris_b( 0b11110000 );
    set_tris_c( 0x00 );
    set_tris_d( 0x00 );
	set_tris_e( 0x03 );
    portc = 0;
    //Habilito os displays
    output_low( PIN_B2 );
    //Faço o setup do timer1 para clock interno e com prescaler de 8. A base de tempo é de 1/( 20MHz/4/8 )= 1.6uS
    setup_timer_1( T1_INTERNAL | T1_DIV_BY_8 );
    //Carrego o timer com 34285 de forma que ele conte ( 65535 - 34285 ) = 31250*1.6uS = 50ms.
    set_timer1( TIMER_CONFIGURATIONS );
    //Habilito as interrupções do timer1 e da porta b
    enable_interrupts( global );
    enable_interrupts( int_timer1 );
    enable_interrupts( int_rb );
	
	printf("Hello Asfalto\n\r");

//dois semaforos em vermelho
	output_high( vermSem1 );
	output_low( amarSem1 );
	output_low( verdeSem1 );
	
	output_high( vermSem2 );
	output_low( amarSem2 );
	output_low( verdeSem2 );

	via1.sema.enable = 1;
	via2.sema.enable = 0;

    while( 1 )
    {

	  handlerControleVel();
	  handlerSemaforo();	
      delay_ms(50);
    }
    
}
Ejemplo n.º 19
0
void main() {
   
   setup_adc_ports(AN0);
   setup_adc(ADC_CLOCK_INTERNAL);
   set_adc_channel(0);
   set_tris_b(0x00);                
   output_b(0x00);
   LED_ON(LEDR);
   LED_OFF(LEDV); 
   usb_init();                      
   usb_task();   //Monitorea el estado de la coneccion conectandose y desconectandose automaticamente
   usb_wait_for_enumeration();  //espera infinitamente hasta que el dispositivo fue enumerado    
   LED_ON(LEDV);
   LED_OFF(LEDR); 
   
   while (TRUE) 
   {
      usb_task();
      if (usb_enumerated()) 
      {
        
            Salida[0]=read_adc();
            usb_put_packet(1, Salida, 1, USB_DTS_TOGGLE);

         if (usb_kbhit(1)) 
         {
         
           usb_get_packet(1, Entrada, 1);
           if (Entrada[0]==1)
            {      
             LED_ON(PIN_B0);
              
            }

            else 
            LED_OFF(PIN_B0);

         }
         
      }
   }
   }
Ejemplo n.º 20
0
//======================================
//Chuong trinh chinh
//======================================
void main()
{
enable_interrupts(int_rda); //Cai datngattruyen thong
ext_int_edge( H_TO_L );
   setup_timer_1(T1_INTERNAL | T1_DIV_BY_8); //Cai dat bo chia Timer 1
enable_interrupts(INT_TIMER1); //Timer1 65536
   set_timer1(3036); //Cai dat Timer 1 ngat trong 0.1s
enable_interrupts(INT_EXT);
enable_interrupts(global);
   //Datcac gia tri ban dau cho cacbien
xung = 0;
vantoc = 0;
Vdat = 0;
kp = 0;
ki = 0;
kpi = 0;
kii = 0;
kd = 0; //Bien TG khoi dong
//Cai dat vao ra
set_tris_a(0xFF);
set_tris_b(0xFF);
set_tris_c(0xc0);
set_tris_d(0x00);
delay_ms(50);
   //Cai dat ADC
setup_adc(ADC_CLOCK_INTERNAL);
setup_adc_ports(RA0_ANALOG);
set_adc_channel(0);
setup_comparator(NC_NC_NC_NC); 
setup_vref(FALSE); 
delay_ms(50);
while(1)
   {
   //Do dong dien
do_dong();
delay_ms(50); 
do_dong();
delay_ms(50);
   //Xuat len may tinh
printf("!%4.0f|%1.3f@",(float)vantoc,(float)ampe);
  }
}
Ejemplo n.º 21
0
void main ()
{

set_tris_a(0xff);
set_tris_c(0x00);
set_tris_b(0x00);

output_c(0x00);
output_b(0x00);

setup_adc_ports(RA0_ANALOG);
set_adc_channel(0);
setup_adc(ADC_CLOCK_DIV_32);

enable_interrupts(int_rtcc);
enable_interrupts(GLOBAL);
set_timer0(0);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_16);


while (true)
{
if(con==9){
cif = read_adc();
cif *= .488281;   //por que Vref / 1024 = 0.004882  x 100

aux=floor(cif); //floor me regresa el entero de cif en aux
dec=cif-aux;

d1=floor(aux/10);
aux-=d1*10;

d2=floor(aux);
d3=floor(dec/0.1);
d4=(floor(dec/0.01))-(d3*10);
con=0;
}

}

}
Ejemplo n.º 22
0
void detect_rb_change() {
   int current;
   static int last=0;

   set_tris_b(0xF0);
   current=PORTB;

   #if LOWTOHIGH
   if ((!bit_test(last,4))&&(bit_test(current,4))) {dbutton4=1;}
   if ((!bit_test(last,5))&&(bit_test(current,5))) {dbutton5=1;}
   if ((!bit_test(last,6))&&(bit_test(current,6))) {dbutton6=1;}
   if ((!bit_test(last,7))&&(bit_test(current,7))) {dbutton7=1;}
   #elif HIGHTOLOW
   if ((!bit_test(current,4))&&(bit_test(last,4))) {dbutton4=1;}
   if ((!bit_test(current,5))&&(bit_test(last,5))) {dbutton5=1;}
   if ((!bit_test(current,6))&&(bit_test(last,6))) {dbutton6=1;}
   if ((!bit_test(current,7))&&(bit_test(last,7))) {dbutton7=1;}
   #endif

   last=current;
}
Ejemplo n.º 23
0
    void main() {

    //setup_adc_ports(NO_ANALOGS|VSS_VDD);
    //setup_adc(ADC_OFF|ADC_TAD_MUL_0);
    //setup_psp(PSP_DISABLED);
    //setup_spi(FALSE);
    //setup_wdt(WDT_OFF);
    setup_timer_0( RTCC_8_BIT|RTCC_DIV_1);
    setup_timer_1(T1_DISABLED);
    //setup_timer_2(T2_DISABLED,0,1);
    //setup_timer_3(T3_DISABLED|T3_DIV_BY_1);
    //setup_comparator(NC_NC_NC_NC);
    //setup_vref(VREF_LOW|-2);
    //setup_low_volt_detect(FALSE);
    //setup_oscillator(OSC_8MHZ);

        set_tris_b(0);

    Rojo=0;
    Verde=0;
    Azul=0;
        Ticks=0;
        ComandoRecibido=false;

        printf ("Jugando con LEDS RGB          Nocturno 2007 - www.micropic.es\n\r\n\r");
        printf ("Introduce el color deseado en formato RxxxGxxxBxxx\n\r");
        printf ("Puedes modificar sólo una componente del color con (R/G/B)xxx\n\r");
        printf ("Si escribes DEMO verás una secuencia de colores\n\r");

        enable_interrupts(INT_RDA);
        enable_interrupts(INT_TIMER0);
        enable_interrupts (GLOBAL);

        while (1) {
                if (ComandoRecibido)
                        ProcesaRGB();
        };

    }
Ejemplo n.º 24
0
//------------------------------------------------------------------------------
void init_prog(void)
{
setup_wdt(WDT_OFF);
setup_adc_ports(NO_ANALOGS|VSS_VDD);
setup_adc(ADC_OFF);
setup_psp(PSP_DISABLED);                                                
setup_spi(SPI_SS_DISABLED);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_16|RTCC_8_BIT);// TIMER0
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_timer_3(T3_DISABLED|T3_DIV_BY_1);
setup_comparator(NC_NC_NC_NC);                                           
setup_vref(FALSE);
setup_low_volt_detect(FALSE);              
setup_oscillator(OSC_32MHZ);                                        

set_tris_a(0x00);
set_tris_b(0x24); 
set_tris_c(0x80);
set_tris_d(0x00);                                      
set_tris_e(0x15);     
set_tris_f(0x58);
set_tris_g(0x10);
output_a(0x00);
output_b(0x00);
output_c(0x00);
output_d(0x00);
output_e(0x00);
output_f(0x00);
output_g(0x00);
// RF Modul and PA/LNA activation
 
   IOpin.modulepower=0;
   IOpin.moduleCTX=1;
   IOpin.moduleCPS=0;
   IOpin.modulePWRUP=1;
   
}
//-----------------------------------------------------------------//
// Programa Principal ---------------------------------------------//
//-----------------------------------------------------------------//
void main() {
   int i;
  set_tris_a(0xFF);      // Puerto A todo entradas
  port_b_pullups(FALSE); // Resistencias de polarización
  set_tris_b(0x38);      //
  set_tris_c(0x00);      // Puerto C todo salidas
  set_tris_d(0x00);     // Puerto D todo salidas

  //Configuro los canales del ADC
  SETUP_ADC_PORTS(AN0_AN1_AN2_AN3_AN4);
  SETUP_ADC(ADC_CLOCK_DIV_8 );
  SETUP_VREF(VREF_HIGH | 6 );


  //Habilito interrupciones
  //enable_interrupts(int_rda);
  //enable_interrupts(global);

  while(1){
  realizar_ensayo();
  //printf("%4ld \r",md);
  }
 }
Ejemplo n.º 26
0
// ***********************************************
// Definicion de las variables
   int teclado()
   {
      
      set_tris_b(0xF0);
      do
      {
         do
         {
            tecla_port=0xF0;
            rbpu=0;
            rbif=0;
            i=1;
            while(rbif==0){}
            delay_ms(30);
            tecla_temp=0xFE;
            do
            {
               tecla_port=tecla_temp;
               tecla=tecla_temp;
               tecla_temp=(tecla_temp<<1)+1;
               i++;
            }while((i<=4) && (tecla_port==tecla));
         }while(tecla_port==tecla);
         tecla=tecla_port;
         i=0;
         while((tabla_tecla[i]!=tecla) && (i<16))
         {
            i++;
         }
      }while(i==16);      
      tecla=tabla_ascii[i];
      rbif=0;
      while(rbif==0){}
      delay_ms(30);
      return(tecla);
}
Ejemplo n.º 27
0
//*****************************************************************************************
//*****************************************************************************************
//P RO G R A M A     P R I N C I P A L
//*****************************************************************************************
//*****************************************************************************************
void main(){
   float32* fltPtr;
   float32 varX,varY,varZ;
   float32 Xp,Yp;
   float32 fx,fy,fz;
   float incX;
   float incY;
   
   char x,y,z;
   char posicion;

   setup_adc_ports(NO_ANALOGS|VSS_VDD);
   setup_adc(ADC_OFF|ADC_TAD_MUL_0);
   setup_psp(PSP_DISABLED);
   setup_spi(SPI_SS_DISABLED);
   setup_spi2(SPI_SS_DISABLED);
   setup_wdt(WDT_OFF);
   setup_timer_0(RTCC_INTERNAL);
   setup_timer_1(T1_DISABLED);
   setup_timer_2(T2_DISABLED,0,1);
   setup_timer_3(T3_DISABLED|T3_DIV_BY_1);
   setup_timer_4(T4_DISABLED,0,1);
   setup_comparator(NC_NC_NC_NC);
   setup_vref(FALSE);

   set_tris_a(0x00);
   set_tris_b(0x00);
   set_tris_c(0xC0);
   set_tris_d(0x00);
   set_tris_e(0x00);

   DELAY_MS(200);

   output_b(0xFF);

   GLCD_init(1);

   DELAY_MS(500);

   output_b(0x00);

   //Setear propiedades de la grafica.
   graph.x1=0.0;
   graph.y1=0.0;
   graph.x2=127.0;
   graph.y2=63.0;

   graph.minX=-1.0;
   graph.maxX=1.0;
   graph.minY=-1.0;
   graph.maxY=1.0;

   graph.minViewX=-2.5;
   graph.maxViewX=2.5;
   graph.minViewY=-1.25;
   graph.maxViewY=1.25;

   printf("Hecho por Bruno Fascendini @ 2009 para uControl y Todopic\r\ncomo parte de proyecto calculadora cientifica con PIC del foro uControl\r\n");
   printf("Parseador version: %s Evaluador version: %s\r\n",ParserVer,EvaluadorVer);
   //menú:
   printf("Ingrese la superficie a graficar: ");

   posicion=0;
   do{
      EquIn[posicion]=getc();
      if(posicion>0 && EquIn[posicion]==8) posicion--; else posicion++;      //delete if delete key pressed...
      if(posicion==BUFFER_SIZE) break;
   }while(EquIn[posicion-1]!=13);
   EquIn[posicion]='\0';

   printf("Ha pedido que se grafique la ecuacion: %s",EquIn);

   printf("Ingrese valor minimo de x: ");
   posicion=0;
   do{
      temp[posicion]=getc();
      if(posicion>0 && temp[posicion]==8) posicion--; else posicion++;      //delete if delete key pressed...
      if(posicion==BUFFER_SIZE) break;
   }while(temp[posicion-1]!=13);
   temp[posicion]='\0';
   graph.minX=atof(temp);
   
   printf("Ingrese valor maximo de x: ");
   posicion=0;
   do{
      temp[posicion]=getc();
      if(posicion>0 && temp[posicion]==8) posicion--; else posicion++;      //delete if delete key pressed...
      if(posicion==BUFFER_SIZE) break;
   }while(temp[posicion-1]!=13);
   temp[posicion]='\0';
   graph.maxX=atof(temp);

   printf("Ingrese valor minimo de y: ");
   posicion=0;
   do{
      temp[posicion]=getc();
      if(posicion>0 && temp[posicion]==8) posicion--; else posicion++;      //delete if delete key pressed...
      if(posicion==BUFFER_SIZE) break;
   }while(temp[posicion-1]!=13);
   temp[posicion]='\0';
   graph.minY=atof(temp);
   
   printf("Ingrese valor maximo de y: ");
   posicion=0;
   do{
      temp[posicion]=getc();
      if(posicion>0 && temp[posicion]==8) posicion--; else posicion++;      //delete if delete key pressed...
      if(posicion==BUFFER_SIZE) break;
   }while(temp[posicion-1]!=13);
   temp[posicion]='\0';
   graph.maxY=atof(temp);

   graph.minViewX=graph.minX;
   graph.maxViewX=graph.maxX;
   graph.minViewY=graph.minY;
   graph.maxViewY=graph.maxY;

   //Calculating centers...
   graph.centerX= (graph.x2-graph.x1)/2;
   graph.centerY= (graph.y2-graph.y1)/2;

   incX=(graph.maxX-graph.minX)/50;       //set step cuantity for X axis
   incY=(graph.maxY-graph.minY)/50;       //set step cuantity for Y axis

   printf("Graficando...\r\n");

   //////////////////////////////////////////////////
   //PROCESO..............
   //comienzo del parseado de la ecuacion ingresada...
   //////////////////////////////////////////////////

   strlwr(EquIn);                        //1) PASAR EQUACION A MINUSCULAS

   //printf("Cadena en minusculas: %s\r\n",EquIn); 
                                        
   strCodificar(EquIn);                   // 2) REDUCIR ECUACION PARA OPTIMIZAR PROCESADO POSTERIOR

   printf("Cadena codificada: %s\r\n",EquIn);

   strPosFijar(EquIn,EquIn);              // 3) Pasar a notación PostFija

   printf("Cadena en notacion postfija: %s\r\n",EquIn);

   //cut unuseful zones...
   //if(graph.minX<graph.minViewX) graph.minX=graph.minViewX;
   //if(graph.maxX>graph.maxViewX) graph.maxX=graph.maxViewX;
   //if(graph.minY<graph.minViewY) graph.minY=graph.minViewY;
   //if(graph.maxY>graph.maxViewY) graph.maxY=graph.maxViewY;

/*
//Ejes!
   varx=0.0;
   varz=0.0;
   for(vary=0.0;Xp>=0;vary+=0.4){
      Xp = RAIZ2SOBRE2 * (varX - varY) + CentroX;
      Yp = -(RAIZ2TERCIOS * varZ - UNOSOBRERAIZ6 * (varX + varY)) + CentroY;
      GLCD_pixel((int8)Xp,(int8)Yp,1);
   }

   vary=0.0;
   varz=0.0;
   for(varx=0.0;Xp<Radius+CentroX;varx+=0.4){
      Xp = RAIZ2SOBRE2 * (varX - varY) + CentroX;
      Yp = -(RAIZ2TERCIOS * varZ - UNOSOBRERAIZ6 * (varX + varY)) + CentroY;
      GLCD_pixel((int8)Xp,(int8)Yp,1);
   }

   varx=0.0;
   vary=0.0;
   for(varz=0.0;Yp>0;varz+=1.0){
      Xp = RAIZ2SOBRE2 * (varX - varY) + CentroX;
      Yp = -(RAIZ2TERCIOS * varZ - UNOSOBRERAIZ6 * (varX + varY)) + CentroY;
      GLCD_pixel((int8)Xp,(int8)Yp,1);
   }
*/


/*
//2D:
for(varX=graph.minX;varX<graph.maxX;varX+=0.1){
   fltPtr=strEvaluar(EquIn,StackNum,&varX,NULL,NULL);
   printf("X: %f Y: %f\r\n",varX,*fltPtr);

   Xp=varX+graph.centerX;
   Yp=graph.centerY-(*fltPtr);

   //ensure that pixel belongs to actual graph section...else do not show it!(out of bounds)
   if(Xp>=graph.x1 && Xp<=graph.x2 && Yp>=graph.y1 && Yp<=graph.y2) GLCD_pixel((int8)Xp,(int8)Yp,1);
}

printf("HECHO!\r\n");
while(1);
*/

//Proyeccion Isométrica...
   for(varY=graph.minY;varY<graph.maxY;varY+=incY){
      for(varX=graph.minX;varX<graph.maxX;varX+=incX){
         //indicate no error...
         errno=0;
         fltPtr=strEvaluar(EquIn,StackNum,&varX,&varY,NULL);
         //if errors during calculating...do not bother at all..
         if(errno) continue;
         
         //calculate isometric proyection
         varZ = *fltPtr;
         Xp = RAIZ2SOBRE2 * (varX - varY);
         Yp = (RAIZ2TERCIOS * varZ - UNOSOBRERAIZ6 * (varX + varY));
            
         //ensure that values are inside drawing zone...
         if(Xp>=graph.minViewX && Xp<=graph.maxViewX && Yp>=graph.minViewY && Yp<=graph.maxViewY){
            //printf("X: %f Y: %f Z: %f\r\n",varX,varY,varZ);
         
            //now let´s ubicate them inside actual graphic bounds...
            Xp=(Xp-graph.minViewX)*(float32)(graph.x2-graph.x1)/(graph.maxViewX-graph.minViewX)+(float32)graph.x1;
            Yp=(float32)graph.y2-((Yp-graph.minViewY)*(float32)(graph.y2-graph.y1)/(graph.maxViewY-graph.minViewY))+(float32)graph.y1; 

            //printf("XP: %f YP: %f\r\n",Xp,Yp);
            if(Xp>=graph.x1 && Xp<=graph.x2 && Yp>=graph.y1 && Yp<=graph.y2) GLCD_pixel((int8)Xp,(int8)Yp,1);            
         }
      }
   }

   printf("Proceso de graficacion finalizado.\r\n");

/*
//polares
  for(varY=-PI/2;varY<PI/2;varY+=PI/63){
      for(varX=-PI;varX<PI;varX+=2*PI/31){
         fX=Radius*cos(varX)*cos(varY);
         fY=Radius*cos(varX)*sin(varY);
         fZ=Radius*sin(varX);

         Xp=Sqrt(2.0) / 2.0 * (fX - fY) * Distance + CentroX;
         Yp = (Sqrt(2.0 / 3.0) * fZ - (1.0 / Sqrt(6.0)) * (fX + fY)) * Distance + CentroY;
         GLCD_pixel((int8)Xp,(int8)Yp,1);
       //printf("Xp: %f Yp: %f\r\n",Xp,Yp);
      }
  }
*/  
  
 //printf("EL resultado de la ecuacion es: %9f\r\n",*fltPtr);
   while(1);
}
Ejemplo n.º 28
0
void main()
{

   setup_adc_ports(NO_ANALOGS);
   setup_adc(ADC_OFF);
   setup_spi(SPI_SS_DISABLED);
   setup_timer_0(RTCC_INTERNAL|RTCC_DIV_32);
   setup_timer_1(T1_DISABLED);
   setup_timer_2(T2_DISABLED,0,1);
   setup_comparator(NC_NC_NC_NC);
   setup_vref(FALSE);
   enable_interrupts(INT_RDA);
   enable_interrupts(INT_TIMER0);
   enable_interrupts(GLOBAL);
   //port_b_pullups(TRUE);
   set_timer0(131);
   // TODO: USER CODE!!

andares[0] = 0;
andares[1] = 0;
andares[2] = 0;
andares[3] = 0;
sinal = 0;

   set_tris_a(0x00); //saída de dados
   set_tris_b(0xfe); //entrada de dados,menos bit 0
   set_tris_c(0xbf); //saída de dados, menos bit 6
   
   while(TRUE){
    conta = 0;
    
         if(andares[0] != 0){
            if(andares[0] == 1) TMP1 = 0; 
            if(andares[0] == 2) TMP1 = 100;
            if(andares[0] == 3) TMP1 = 200;
            if(andares[0] == 4) TMP1 = 300;
            
          if(TMP2 < TMP1) motor_passo_frente(TMP1-TMP2);
          else motor_passo_tras(TMP2-TMP1);
     
          conta = 0;
          sinal = 1;
          parar_motor_passo();
          printf("Você está no andar %d",andares[0]);
          tira_andar(andares);
          while(conta != 125);
          sinal = 0;

         }else{
          parar_motor_passo();
          sinal = 1;
        }

    TMP2 = TMP1;
     
    if(!parada){
    while(!parada){
    delay_ms(30);
    parou = 1;
    }
    }

       if(parou){
           printf("Opa!parada de emergência");
           sinal = 0; 
           
       TMP2 = TMP1;
   
            do{
            parar_motor_passo();
            
            if(!parada){
            while(!parada){
            delay_ms(30);
            parou = 0;
            }
            }while(!parou);
            printf("Prosseguindo...");
            sinal = 1;
        }    

        if(!andar1 || !andar2 || !andar3 || !andar4){
          while(!andar1 || !andar2 || !andar3 || !andar4){
            delay_ms(30);
            if(!andar1) botao = 1; 
            if(!andar2) botao = 2;
            if(!andar3) botao = 3;
            if(!andar4) botao = 4;
            insere_andar(andares,i);
            ordena(andares);
          }
        }

debug();
         
               
   }

}

}
Ejemplo n.º 29
0
void main()
{

   setup_adc_ports(NO_ANALOGS|VSS_VDD);
   setup_adc(ADC_CLOCK_DIV_2);
   setup_psp(PSP_DISABLED);
   setup_spi(SPI_SS_DISABLED);
   setup_wdt(WDT_OFF);
   setup_timer_0(RTCC_INTERNAL);
   setup_timer_1(T1_DISABLED);
   setup_timer_2(T2_DISABLED,0,1);
   setup_timer_3(T3_DISABLED|T3_DIV_BY_1);
   setup_comparator(NC_NC_NC_NC);
   setup_vref(FALSE);
   enable_interrupts(INT_TIMER0);
   enable_interrupts(GLOBAL);
//Setup_Oscillator parameter not selected from Intr Oscillator Config tab

   set_tris_a(0b00000011);
   set_tris_b(0b00000000);
   set_tris_c(0b10110011);
   set_tris_d(0b11110000);
   set_tris_e(0b00000100);
   
   while(1)
   {
  
      // waits for B1 to go high
      while ( !input(PIN_B1) )
      {}




   
      //PE-
      playSound(NOTE_SOL3,TEMPS_NOIRE);
      delay_us(WAIT);
      //--------------------------------
      //tit
      playSound(NOTE_DO4,TEMPS_NOIRE);
      delay_us(WAIT);
      //pa-
      playSound(NOTE_DO4,TEMPS_NOIRE);
      delay_us(WAIT);
      //pa
      playSound(NOTE_DO4,TEMPS_NOIRE);
      delay_us(WAIT);
      //Noe-
      playSound(NOTE_RE4,TEMPS_NOIRE);
      delay_us(WAIT);
      //--------------------------------
      //el
      playSound(NOTE_DO4,TEMPS_BLANCHE);
      playSound(NOTE_DO4,TEMPS_NOIRE);
      delay_us(WAIT);
      //Quand
      playSound(NOTE_DO4,TEMPS_CROCHE);
      delay_us(WAIT);
      //tu
      playSound(NOTE_RE4,TEMPS_CROCHE);
      delay_us(WAIT);
      //--------------------------------
      //Des-
      playSound(NOTE_MI4,TEMPS_NOIRE);
      delay_us(WAIT);
      //cen-
      playSound(NOTE_MI4,TEMPS_NOIRE);
      delay_us(WAIT);
      //dras
      playSound(NOTE_MI4,TEMPS_NOIRE);
      delay_us(WAIT);
      //du
      playSound(NOTE_FA4,TEMPS_NOIRE);
      delay_us(WAIT);
      //--------------------------------
      //ciel
      playSound(NOTE_MI4,TEMPS_BLANCHE);
      playSound(NOTE_MI4,TEMPS_NOIRE);
      delay_us(WAIT);
      //A-
      playSound(NOTE_RE4,TEMPS_NOIRE);
      delay_us(WAIT);
      //--------------------------------
      //vec
      playSound(NOTE_DO4,TEMPS_NOIRE);
      playSound(NOTE_DO4,TEMPS_CROCHE);
      delay_us(WAIT);
      //tes
      playSound(NOTE_DO4,TEMPS_CROCHE);
      delay_us(WAIT);
      //jou-
      playSound(NOTE_DO4,TEMPS_CROCHE);
      delay_us(WAIT);
      //ets
      playSound(NOTE_DO4,TEMPS_CROCHE);
      delay_us(WAIT);
      //par
      playSound(NOTE_SI3,TEMPS_CROCHE);
      delay_us(WAIT);
      //mi-
      playSound(NOTE_LA3,TEMPS_CROCHE);
      delay_us(WAIT);
      //--------------------------------
      //liers
      playSound(NOTE_SOL3,TEMPS_BLANCHE);
      playSound(NOTE_SOL3,TEMPS_NOIRE);
      delay_us(WAIT);
      //N'ou-
      playSound(NOTE_SOL3,TEMPS_CROCHE);
      delay_us(WAIT);
      //blie
      playSound(NOTE_SOL3,TEMPS_CROCHE);
      delay_us(WAIT);
      //--------------------------------
      //pas
      playSound(NOTE_DO4,TEMPS_BLANCHE);
      delay_us(WAIT);
      //mon
      playSound(NOTE_DO4,TEMPS_CROCHE);
      delay_us(WAIT);
      //pet-
      playSound(NOTE_DO4,TEMPS_CROCHE);
      delay_us(WAIT);
      //tit
      playSound(NOTE_SI3,TEMPS_CROCHE);
      delay_us(WAIT);
      //pa-
      playSound(NOTE_DO4,TEMPS_CROCHE);
      delay_us(WAIT);
      //--------------------------------
      //nier
      playSound(NOTE_RE4,TEMPS_BLANCHE);
      playSound(NOTE_RE4,TEMPS_NOIRE);
      delay_us(WAIT);
      //Mais
      playSound(NOTE_SOL3,TEMPS_NOIRE);
      delay_us(WAIT);
      //--------------------------------
      //a-
      playSound(NOTE_DO4,TEMPS_NOIRE);
      delay_us(WAIT);
      //vant
      playSound(NOTE_DO4,TEMPS_NOIRE);
      delay_us(WAIT);
      //de
      playSound(NOTE_DO4,TEMPS_NOIRE);
      delay_us(WAIT);
      //par-
      playSound(NOTE_RE4,TEMPS_NOIRE);
      delay_us(WAIT);
      //--------------------------------
      //tir
      playSound(NOTE_DO4,TEMPS_BLANCHE);
      playSound(NOTE_DO4,TEMPS_NOIRE);
      delay_us(WAIT);
      //il
      playSound(NOTE_DO4,TEMPS_CROCHE);
      delay_us(WAIT);
      //fau-
      playSound(NOTE_RE4,TEMPS_CROCHE);
      delay_us(WAIT);
      //--------------------------------
      //dra
      playSound(NOTE_MI4,TEMPS_NOIRE);
      delay_us(WAIT);
      //bien
      playSound(NOTE_MI4,TEMPS_NOIRE);
      delay_us(WAIT);
      //te
      playSound(NOTE_MI4,TEMPS_NOIRE);
      delay_us(WAIT);
      //cou-
      playSound(NOTE_FA4,TEMPS_NOIRE);
      delay_us(WAIT);
      //--------------------------------
      //vrir
      playSound(NOTE_MI4,TEMPS_BLANCHE);
      playSound(NOTE_MI4,TEMPS_NOIRE);
      delay_us(WAIT);
      //De-
      playSound(NOTE_RE4,TEMPS_NOIRE);
      delay_us(WAIT);
      //--------------------------------
      //hors
      playSound(NOTE_DO4,TEMPS_NOIRE);
      playSound(NOTE_DO4,TEMPS_CROCHE);
      delay_us(WAIT);
      //il
      playSound(NOTE_DO4,TEMPS_CROCHE);
      delay_us(WAIT);
      //fait
      playSound(NOTE_DO4,TEMPS_CROCHE);
      delay_us(WAIT);
      //dé-
      playSound(NOTE_DO4,TEMPS_CROCHE);
      delay_us(WAIT);
      //jà
      playSound(NOTE_SI3,TEMPS_CROCHE);
      delay_us(WAIT);
      //bien
      playSound(NOTE_LA3,TEMPS_CROCHE);
      delay_us(WAIT);
      //--------------------------------
      //froid
      playSound(NOTE_SOL3,TEMPS_BLANCHE);
      playSound(NOTE_SOL3,TEMPS_NOIRE);
      delay_us(WAIT);
      //C'est
      playSound(NOTE_SOL3,TEMPS_CROCHE);
      delay_us(WAIT);
      //un
      playSound(NOTE_SOL3,TEMPS_CROCHE);
      delay_us(WAIT);
      //--------------------------------
      //peu
      playSound(NOTE_DO4,TEMPS_BLANCHE);
      delay_us(WAIT);
      //a
      playSound(NOTE_DO4,TEMPS_CROCHE);
      delay_us(WAIT);
      //cau-
      playSound(NOTE_DO4,TEMPS_CROCHE);
      delay_us(WAIT);
      //se
      playSound(NOTE_RE4,TEMPS_CROCHE);
      delay_us(WAIT);
      //de
      playSound(NOTE_RE4,TEMPS_CROCHE);
      delay_us(WAIT);
      //--------------------------------
      //Moi
      playSound(NOTE_DO4,TEMPS_RONDE);
      delay_us(WAIT);
      //--------------------------------
      //Il
      playSound(NOTE_LA3,TEMPS_CROCHE);
      delay_us(WAIT);
      //me
      playSound(NOTE_LA3,TEMPS_CROCHE);
      delay_us(WAIT);
      //tar-
      playSound(NOTE_LA3,TEMPS_CROCHE);
      delay_us(WAIT);
      //de
      playSound(NOTE_LA3,TEMPS_CROCHE);
      delay_us(WAIT);
      //tant
      playSound(NOTE_LA3,TEMPS_NOIRE);
      delay_us(WAIT);
      //que
      playSound(NOTE_LA3,TEMPS_CROCHE);
      delay_us(WAIT);
      //le
      playSound(NOTE_SI3,TEMPS_CROCHE);
      delay_us(WAIT);
      //--------------------------------
      //jour
      playSound(NOTE_DO4,TEMPS_NOIRE);
      playSound(NOTE_DO4,TEMPS_CROCHE);
      delay_us(WAIT);
      //se
      playSound(NOTE_LA3,TEMPS_CROCHE);
      delay_us(WAIT);
      //lè-
      playSound(NOTE_LA3,TEMPS_NOIRE);
      delay_us(WAIT);
      //ve
      playSound(NOTE_SOL3,TEMPS_NOIRE);
      delay_us(WAIT);
      //--------------------------------
      //Pour
      playSound(NOTE_DO4,TEMPS_CROCHE);
      delay_us(WAIT);
      //voir
      playSound(NOTE_DO4,TEMPS_CROCHE);
      delay_us(WAIT);
      //si
      playSound(NOTE_DO4,TEMPS_CROCHE);
      delay_us(WAIT);
      //tu
      playSound(NOTE_DO4,TEMPS_CROCHE);
      delay_us(WAIT);
      //m'as
      playSound(NOTE_DO4,TEMPS_NOIRE);
      delay_us(WAIT);
      //ap-
      playSound(NOTE_SI3,TEMPS_CROCHE);
      delay_us(WAIT);
      //por-
      playSound(NOTE_DO4,TEMPS_CROCHE);
      delay_us(WAIT);
      //--------------------------------
      //té
      playSound(NOTE_RE4,TEMPS_RONDE);
      delay_us(WAIT);
      //--------------------------------
      //tous
      playSound(NOTE_MI4,TEMPS_CROCHE);
      delay_us(WAIT);
      //les
      playSound(NOTE_MI4,TEMPS_CROCHE);
      delay_us(WAIT);
      //beaux
      playSound(NOTE_MI4,TEMPS_CROCHE);
      delay_us(WAIT);
      //jou-
      playSound(NOTE_MI4,TEMPS_CROCHE);
      delay_us(WAIT);
      //joux
      playSound(NOTE_MI4,TEMPS_NOIRE);
      delay_us(WAIT);
      //que
      playSound(NOTE_RE4,TEMPS_CROCHE);
      delay_us(WAIT);
      //je
      playSound(NOTE_MI4,TEMPS_CROCHE);
      delay_us(WAIT);
      //--------------------------------
      //vois
      playSound(NOTE_FA4,TEMPS_NOIRE);
      playSound(NOTE_FA4,TEMPS_CROCHE);
      delay_us(WAIT);
      //en
      playSound(NOTE_RE4,TEMPS_CROCHE);
      delay_us(WAIT);
      //re-
      playSound(NOTE_DO4,TEMPS_NOIRE);
      delay_us(WAIT);
      //ve
      playSound(NOTE_SI3,TEMPS_NOIRE);
      delay_us(WAIT);
      //--------------------------------
      //et
      playSound(NOTE_MI4,TEMPS_CROCHE);
      delay_us(WAIT);
      playSound(NOTE_MI4,TEMPS_CROCHE);
      delay_us(WAIT);
      //que
      playSound(NOTE_MI4,TEMPS_CROCHE);
      delay_us(WAIT);
      //je
      playSound(NOTE_MI4,TEMPS_CROCHE);
      delay_us(WAIT);
      //t'ai
      playSound(NOTE_FA4,TEMPS_NOIRE);
      delay_us(WAIT);
      //com-
      playSound(NOTE_FA4,TEMPS_CROCHE);
      delay_us(WAIT);
      //man-
      playSound(NOTE_FA4,TEMPS_CROCHE);
      delay_us(WAIT);
      //--------------------------------
      //de
      playSound(NOTE_SOL4,TEMPS_BLANCHE);
      playSound(NOTE_SOL4,TEMPS_BLANCHE);
      delay_us(WAIT);
       //PE-
      playSound(NOTE_SOL3,TEMPS_NOIRE);
      delay_us(WAIT);
      //--------------------------------
      //tit
      playSound(NOTE_DO4,TEMPS_NOIRE);
      delay_us(WAIT);
      //pa-
      playSound(NOTE_DO4,TEMPS_NOIRE);
      delay_us(WAIT);
      //pa
      playSound(NOTE_DO4,TEMPS_NOIRE);
      delay_us(WAIT);
      //Noe-
      playSound(NOTE_RE4,TEMPS_NOIRE);
      delay_us(WAIT);
      //--------------------------------
      //el
      playSound(NOTE_DO4,TEMPS_BLANCHE);
      playSound(NOTE_DO4,TEMPS_NOIRE);
      delay_us(WAIT);
      //Quand
      playSound(NOTE_DO4,TEMPS_CROCHE);
      delay_us(WAIT);
      //tu
      playSound(NOTE_RE4,TEMPS_CROCHE);
      delay_us(WAIT);
      //--------------------------------
      //Des-
      playSound(NOTE_MI4,TEMPS_NOIRE);
      delay_us(WAIT);
      //cen-
      playSound(NOTE_MI4,TEMPS_NOIRE);
      delay_us(WAIT);
      //dras
      playSound(NOTE_MI4,TEMPS_NOIRE);
      delay_us(WAIT);
      //du
      playSound(NOTE_FA4,TEMPS_NOIRE);
      delay_us(WAIT);
      //--------------------------------
      //ciel
      playSound(NOTE_MI4,TEMPS_BLANCHE);
      playSound(NOTE_MI4,TEMPS_NOIRE);
      delay_us(WAIT);
      //A-
      playSound(NOTE_RE4,TEMPS_NOIRE);
      delay_us(WAIT);
      //--------------------------------
      //vec
      playSound(NOTE_DO4,TEMPS_NOIRE);
      playSound(NOTE_DO4,TEMPS_CROCHE);
      delay_us(WAIT);
      //tes
      playSound(NOTE_DO4,TEMPS_CROCHE);
      delay_us(WAIT);
      //jou-
      playSound(NOTE_DO4,TEMPS_CROCHE);
      delay_us(WAIT);
      //ets
      playSound(NOTE_DO4,TEMPS_CROCHE);
      delay_us(WAIT);
      //par
      playSound(NOTE_SI3,TEMPS_CROCHE);
      delay_us(WAIT);
      //mi-
      playSound(NOTE_LA3,TEMPS_CROCHE);
      delay_us(WAIT);
      //--------------------------------
      //liers
      playSound(NOTE_SOL3,TEMPS_BLANCHE);
      playSound(NOTE_SOL3,TEMPS_NOIRE);
      delay_us(WAIT);
      //N'ou-
      playSound(NOTE_SOL3,TEMPS_CROCHE);
      delay_us(WAIT);
      //blie
      playSound(NOTE_SOL3,TEMPS_CROCHE);
      delay_us(WAIT);
      //--------------------------------
      //pas
      playSound(NOTE_DO4,TEMPS_BLANCHE);
      delay_us(WAIT);
      //mon
      playSound(NOTE_DO4,TEMPS_CROCHE);
      delay_us(WAIT);
      //pet-
      playSound(NOTE_DO4,TEMPS_CROCHE);
      delay_us(WAIT);
      //tit
      playSound(NOTE_SI3,TEMPS_CROCHE);
      delay_us(WAIT);
      //pa-
      playSound(NOTE_DO4,TEMPS_CROCHE);
      delay_us(WAIT);
      //--------------------------------
      //nier
      playSound(NOTE_RE4,TEMPS_BLANCHE);
      playSound(NOTE_RE4,TEMPS_NOIRE);
      delay_us(WAIT);
      //Mais
      playSound(NOTE_SOL3,TEMPS_NOIRE);
      delay_us(WAIT);
      //--------------------------------
      //a-
      playSound(NOTE_DO4,TEMPS_NOIRE);
      delay_us(WAIT);
      //vant
      playSound(NOTE_DO4,TEMPS_NOIRE);
      delay_us(WAIT);
      //de
      playSound(NOTE_DO4,TEMPS_NOIRE);
      delay_us(WAIT);
      //par-
      playSound(NOTE_RE4,TEMPS_NOIRE);
      delay_us(WAIT);
      //--------------------------------
      //tir
      playSound(NOTE_DO4,TEMPS_BLANCHE);
      playSound(NOTE_DO4,TEMPS_NOIRE);
      delay_us(WAIT);
      //il
      playSound(NOTE_DO4,TEMPS_CROCHE);
      delay_us(WAIT);
      //fau-
      playSound(NOTE_RE4,TEMPS_CROCHE);
      delay_us(WAIT);
      //--------------------------------
      //dra
      playSound(NOTE_MI4,TEMPS_NOIRE);
      delay_us(WAIT);
      //bien
      playSound(NOTE_MI4,TEMPS_NOIRE);
      delay_us(WAIT);
      //te
      playSound(NOTE_MI4,TEMPS_NOIRE);
      delay_us(WAIT);
      //cou-
      playSound(NOTE_FA4,TEMPS_NOIRE);
      delay_us(WAIT);
      //--------------------------------
      //vrir
      playSound(NOTE_MI4,TEMPS_BLANCHE);
      playSound(NOTE_MI4,TEMPS_NOIRE);
      delay_us(WAIT);
      //De-
      playSound(NOTE_RE4,TEMPS_NOIRE);
      delay_us(WAIT);
      //--------------------------------
      //hors
      playSound(NOTE_DO4,TEMPS_NOIRE);
      playSound(NOTE_DO4,TEMPS_CROCHE);
      delay_us(WAIT);
      //il
      playSound(NOTE_DO4,TEMPS_CROCHE);
      delay_us(WAIT);
      //fait
      playSound(NOTE_DO4,TEMPS_CROCHE);
      delay_us(WAIT);
      //dé-
      playSound(NOTE_DO4,TEMPS_CROCHE);
      delay_us(WAIT);
      //jà
      playSound(NOTE_SI3,TEMPS_CROCHE);
      delay_us(WAIT);
      //bien
      playSound(NOTE_LA3,TEMPS_CROCHE);
      delay_us(WAIT);
      //--------------------------------
      //froid
      playSound(NOTE_SOL3,TEMPS_BLANCHE);
      playSound(NOTE_SOL3,TEMPS_NOIRE);
      delay_us(WAIT);
      //C'est
      playSound(NOTE_SOL3,TEMPS_CROCHE);
      delay_us(WAIT);
      //un
      playSound(NOTE_SOL3,TEMPS_CROCHE);
      delay_us(WAIT);
      //--------------------------------
      //peu
      playSound(NOTE_DO4,TEMPS_BLANCHE);
      delay_us(WAIT);
      //a
      playSound(NOTE_DO4,TEMPS_CROCHE);
      delay_us(WAIT);
      //cau-
      playSound(NOTE_DO4,TEMPS_CROCHE);
      delay_us(WAIT);
      //se
      playSound(NOTE_RE4,TEMPS_CROCHE);
      delay_us(WAIT);
      //de
      playSound(NOTE_RE4,TEMPS_CROCHE);
      delay_us(WAIT);
      //--------------------------------
      //Moi
      playSound(NOTE_DO4,TEMPS_BLANCHE);
      playSound(NOTE_DO4,TEMPS_NOIRE);
      delay_us(WAIT);
      
      playSound(NOTE_SOL3,TEMPS_NOIRE);
      delay_us(WAIT);
      //--------------------------------
      playSound(NOTE_LA3,TEMPS_NOIRE);
      delay_us(WAIT);
      playSound(NOTE_DO4,TEMPS_NOIRE);
      delay_us(WAIT);
      playSound(NOTE_RE4,TEMPS_NOIRE);
      delay_us(WAIT);
      playSound(NOTE_FA4,TEMPS_NOIRE);
      delay_us(WAIT);
      //--------------------------------
      playSound(NOTE_SOL4,TEMPS_RONDE);
      delay_us(WAIT);
   }
   
   
   
}
Ejemplo n.º 30
0
void InitialChip(void)
{
   setup_comparator(NC_NC_NC_NC);   //Input Digital
   set_tris_b(0B00000000);
   set_tris_c(0B10000000);
}