Autor Tema: Dudas en crear Funcion  (Leído 1167 veces)

0 Usuarios y 1 Visitante están viendo este tema.

Desconectado cvargcal

  • PIC16
  • ***
  • Mensajes: 166
Dudas en crear Funcion
« en: 30 de Mayo de 2016, 15:53:13 »
Hice una pequeña función para un blink LED

Código: C
  1. #define PILOTO     PIN_C2    // Piloto  
  2. void blink_led(int1 time_up,int time_down );  
  3.  
  4. //******* Blink LED *********************
  5. void blink_led(int1 time_up,int time_down )          
  6. {
  7.       output_high(PILOTO); delay_ms(time_up);
  8.       output_low(PILOTO); delay_ms(time_down);
  9. }

Funciona bien, pero quiero hacerla mas general, es decir para el pin que yo quiera... así:

Código: C
  1. void blink_led(PIN , int1 time_up,int time_down )
  2. {
  3.       output_high(PIN); delay_ms(time_up);
  4.       output_low(PIN); delay_ms(time_down);
  5. }

¿deque forma se puede asignar el bit a PIN?

Desconectado KILLERJC

  • Colaborador
  • DsPIC33
  • *****
  • Mensajes: 8242
Re:Dudas en crear Funcion
« Respuesta #1 en: 30 de Mayo de 2016, 16:13:04 »
No probaste asi ?, con un int al frente ? o con un int32 o un int16 ?

Código: C
  1. void blink_led(int PIN , int1 time_up,int time_down )
  2. {
  3.       output_high(PIN); delay_ms(time_up);
  4.       output_low(PIN); delay_ms(time_down);
  5. }

Desconectado cvargcal

  • PIC16
  • ***
  • Mensajes: 166
Re:Dudas en crear Funcion
« Respuesta #2 en: 30 de Mayo de 2016, 18:33:58 »
No probaste asi ?, con un int al frente ? o con un int32 o un int16 ?

Código: C
  1. void blink_led(int PIN , int1 time_up,int time_down )
  2. {
  3.       output_high(PIN); delay_ms(time_up);
  4.       output_low(PIN); delay_ms(time_down);
  5. }

Gracias. Ahora si funciona... por casualidad formatee el pc y ahora si me deja compilar...


 

anything