# 9 - Teclado Matricial

> **mikroC PRO for PIC**
>
> [**PIC18F4550 / PIC18F45K50**](https://docs.microside.com/practicas/mikroc-pro-for-pic/pic18f4550-or-pic18f45k50)

<figure><img src="/files/g3YRF5lOvR3Vm2gMlzCJ" alt=""><figcaption></figcaption></figure>

## **Introducción**

En esta práctica se implementa el encendido y apagado de un LED, haciendo uso de un teclado matricial 4×4. Para encender el LED se presiona la tecla 1 y para apagarlo se presiona la tecla 0.

## **Descripción**

En esta práctica se realiza el control de encendido y apagado del LED incluido en la tarjeta **X-TRAINER** con el **PIC18F4550/PIC18F45K50**. También se utiliza un teclado matricial de 4×4, el cual está conectado en el puerto B con 4 resistencias configuradas como pull-down (B0-B3). Para encender el LED se presiona la tecla 1 y para apagar el LED se presiona la tecla 0.

**Materiales:**

1 x Tarjeta **X-TRAINER**. [**Manuales**](https://docs.microside.com/tarjetas-de-desarrollo/x-trainer) | [**Comprar**](https://www.microside.com/shop/category/entrenadores-pic-1)

1 x Teclado matricial 4×4.

4 x Resistencias 1 kOhms.

1 x Protoboard de 830 puntos.

1 x Juego de cables Dupont.

1 x Cable micro USB.

**Software:**

Windows 7 o posterior.

mikroC PRO Compiler. [**Descarga**](https://www.mikroe.com/mikroc-pic)

X-TRAINER Suite v1.0 [**Descarga**](https://raw.githubusercontent.com/MICROSIDE-TECHNOLOGY/microside_download_archive/main/Tools/X-TRAINER%20Suite/X-TRAINER%20Suite%20Setup.zip)

## **Procedimiento**

**1.** En el apartado de “[**Diagrama Esquemático**](#diagrama-esquematico)” selecciona el modelo de tu tarjeta, realiza las conexiones que se muestran en la imagen y conéctala a la computadora.

{% hint style="info" %}
Las conexiones mostradas en los diagramas esquemáticos son las mismas ya sea que la tarjeta **X-TRAINER** posea el **PIC18F4550** o el **PIC18F45K50**.
{% endhint %}

**2.** Ejecuta **mikroC PRO compiler**, crea un nuevo proyecto con el código fuente que se encuentra en el apartado "[**Código**](#codigo)" y compila el programa.

{% hint style="success" %}
Si tienes dudas de cómo realizar los pasos anteriores puedes encontrar un manual de **mikroC PRO compiler** a través del siguiente[ ](https://docs.microside.com/manuales-de-usuario/ides/pic-c-compiler-ccs)[**link**](https://docs.microside.com/practicas/ides/mikroc-pro-for-pic).
{% endhint %}

**3.** Abre el **Software X-TRAINER Suite v1.0** en el apartado **PIC18F4550/45K50**, selecciona el archivo .hex generado al compilar el proyecto y programa la tarjeta.

{% hint style="success" %}
Si tienes dudas de cómo realizar los pasos anteriores puedes encontrar un manual del **Software X-TRAINER Suite v1.0**. a través del siguiente[ **link**](https://docs.microside.com/tarjetas-de-desarrollo/software-x-trainer-suite).
{% endhint %}

**4.** Al terminar de programar, la tarjeta **X-TRAINER** se reiniciará automáticamente y se ejecutará el programa de esta práctica.

## **Diagrama esquemático**

Selecciona el modelo de tu tarjeta **X-TRAINER.**

{% tabs %}
{% tab title="LITE M R2" %}

<figure><img src="https://raw.githubusercontent.com/MICROSIDE-TECHNOLOGY/9-Keyboard-mikroC-PRO-for-PIC-PIC18F4550-45K50/main/Diagrama%20de%20conexión/X-TRAINER_Lite-M-r2_Practica-9_Microside_03.png" alt=""><figcaption></figcaption></figure>
{% endtab %}

{% tab title="LITE M R3" %}

<figure><img src="/files/NpFjnguHpz2nnzXuYKoz" alt=""><figcaption></figcaption></figure>
{% endtab %}

{% tab title="LITE F" %}

<figure><img src="https://raw.githubusercontent.com/MICROSIDE-TECHNOLOGY/9-Keyboard-mikroC-PRO-for-PIC-PIC18F4550-45K50/main/Diagrama%20de%20conexión/X-TRAINER_LITE-F_Practica-9_Microside_02.png" alt=""><figcaption></figcaption></figure>
{% endtab %}

{% tab title="DIP" %}

<figure><img src="https://raw.githubusercontent.com/MICROSIDE-TECHNOLOGY/9-Keyboard-mikroC-PRO-for-PIC-PIC18F4550-45K50/main/Diagrama%20de%20conexión/X-TRAINER_DIP_Practica-10_Microside_02.png" alt=""><figcaption></figcaption></figure>
{% endtab %}

{% tab title="DIP R3" %}

<figure><img src="/files/EK1nERP9xB8OVzFPkqnc" alt=""><figcaption></figcaption></figure>

{% endtab %}

{% tab title="PRO R2" %}

<figure><img src="https://raw.githubusercontent.com/MICROSIDE-TECHNOLOGY/9-Keyboard-mikroC-PRO-for-PIC-PIC18F4550-45K50/main/Diagrama%20de%20conexión/X-TRAINER_PRO-r2_Practica-9_Microside_01-2.png" alt=""><figcaption></figcaption></figure>
{% endtab %}

{% tab title="PRO R3" %}

<figure><img src="/files/wUzQIE9Hg9p2kIu1rdlY" alt=""><figcaption></figcaption></figure>
{% endtab %}

{% tab title="PRO R4" %}

<figure><img src="/files/s2yAvc9ajsmQ1vS9hWMV" alt=""><figcaption></figcaption></figure>
{% endtab %}
{% endtabs %}

## **Código**

{% tabs %}
{% tab title="PIC18F4550" %}
{% embed url="<https://gist.github.com/microside-mx/df35b0ba39e62d2659b7bbca93b9d4fc>" %}
{% endtab %}

{% tab title="PIC18F45K50" %}
{% embed url="<https://gist.github.com/microside-mx/4499d678f5525111d412c1e2f733265f>" %}
{% endtab %}
{% endtabs %}

## **Descargas**

<table data-card-size="large" data-view="cards"><thead><tr><th align="center"></th><th data-hidden data-card-target data-type="content-ref"></th></tr></thead><tbody><tr><td align="center"><mark style="color:green;"><strong>Software X-TRAINER Suite v1.0</strong></mark></td><td><a href="https://raw.githubusercontent.com/MICROSIDE-TECHNOLOGY/microside_download_archive/main/Tools/X-TRAINER%20Suite/X-TRAINER%20Suite%20Setup.zip">https://raw.githubusercontent.com/MICROSIDE-TECHNOLOGY/microside_download_archive/main/Tools/X-TRAINER%20Suite/X-TRAINER%20Suite%20Setup.zip</a></td></tr><tr><td align="center"><mark style="color:green;"><strong>Proyecto</strong></mark></td><td><a href="https://github.com/MICROSIDE-TECHNOLOGY/9-Keyboard-mikroC-PRO-for-PIC-PIC18F4550-45K50/archive/refs/heads/main.zip">https://github.com/MICROSIDE-TECHNOLOGY/9-Keyboard-mikroC-PRO-for-PIC-PIC18F4550-45K50/archive/refs/heads/main.zip</a></td></tr></tbody></table>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.microside.com/practicas/mikroc-pro-for-pic/pic18f4550-or-pic18f45k50/9-teclado-matricial.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
