# 10 - Teclado Matricial

> **PIC C Compiler CCS**
>
> [**PIC18F4550 / PIC18F45K50**](https://docs.microside.com/practicas/pic-c-compiler-ccs/pic18f4550-or-pic18f45k50)

<figure><img src="https://177299348-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbyV2zAlQAiqg46a3Lr8z%2Fuploads%2FjD9WSOWiEQ6o5OkOeewt%2FTeclado%20matricial.png?alt=media&#x26;token=ec0a408b-1ac4-4c42-a2de-53f4df826ad9" 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 8.1 o posterior.

PIC C Compiler v5.069 o posterior. [**Descarga**](http://www.ccsinfo.com/ccsfreedemo.php)

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 **PIC C 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 **PIC C Compiler** a través del siguiente [**link**](https://docs.microside.com/practicas/ides/pic-c-compiler-ccs).
{% 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/10-Teclado-Matricial-CCS-PIC18F4550-45K50/main/Diagrama%20de%20conexi%C3%B3n/X-TRAINER_Lite-M-r2_Practica-10_Microside_02.png" alt=""><figcaption></figcaption></figure>
{% endtab %}

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

<figure><img src="https://177299348-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbyV2zAlQAiqg46a3Lr8z%2Fuploads%2FqqOS67uWe9ksi3TQfZRL%2FTeclado%20Matricial%20PIC18F44550%20o%20PIC18F45K50%20X-TRAINER%20LITE%20M%20MICROSIDE.webp?alt=media&#x26;token=0f8569e3-6d88-4824-a500-6f9b9c8dbe47" alt=""><figcaption></figcaption></figure>
{% endtab %}

{% tab title="LITE F" %}

<figure><img src="https://raw.githubusercontent.com/MICROSIDE-TECHNOLOGY/10-Teclado-Matricial-CCS-PIC18F4550-45K50/main/Diagrama%20de%20conexi%C3%B3n/X-TRAINER_LITE-F_Practica-10_Microside_01.png" alt=""><figcaption></figcaption></figure>
{% endtab %}

{% tab title="DIP" %}

<figure><img src="https://raw.githubusercontent.com/MICROSIDE-TECHNOLOGY/10-Teclado-Matricial-CCS-PIC18F4550-45K50/main/Diagrama%20de%20conexi%C3%B3n/X-TRAINER_DIP_Practica-10_Microside_01.png" alt=""><figcaption></figcaption></figure>
{% endtab %}

{% tab title="DIP R3" %}

<figure><img src="https://177299348-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbyV2zAlQAiqg46a3Lr8z%2Fuploads%2Fl6hMpHXQOMNeMHsIk9af%2Fhands-on-pic18f-keyboard-x-trainer-dip-r3-ccs.png?alt=media&#x26;token=e44be267-d5ac-427e-9bf7-6c5c739f7f99" alt=""><figcaption></figcaption></figure>

{% endtab %}

{% tab title="PRO R2" %}

<figure><img src="https://raw.githubusercontent.com/MICROSIDE-TECHNOLOGY/10-Teclado-Matricial-CCS-PIC18F4550-45K50/main/Diagrama%20de%20conexi%C3%B3n/X-TRAINER_PRO-r2_Practica-10_Microside_01-1.png" alt=""><figcaption></figcaption></figure>
{% endtab %}

{% tab title="PRO R3" %}

<figure><img src="https://177299348-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbyV2zAlQAiqg46a3Lr8z%2Fuploads%2FWtEHnCEJ9OrHi6VrAlMx%2F10%20Teclado%20Matrical%20X%20Trainer%20Pro%2018_PIC%20C.png?alt=media&#x26;token=45dd6ebb-68c9-457a-98ce-cb6f86416ccd" alt=""><figcaption></figcaption></figure>
{% endtab %}

{% tab title="PRO R4" %}

<figure><img src="https://177299348-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbyV2zAlQAiqg46a3Lr8z%2Fuploads%2FApAUEaG3TNm1yiA638nc%2FTeclado%20Matricial%20PIC18F4550%20%20o%20PIC18F45K50%20X-TRAINER%20PRO%20R4%20MICROSIDE.webp?alt=media&#x26;token=41056359-bbec-45cc-871c-923f1b360072" alt=""><figcaption></figcaption></figure>
{% endtab %}
{% endtabs %}

## **Código**

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

{% tab title="PIC18F45K50" %}
{% embed url="<https://gist.github.com/microside-mx/8e5d11bc382a675f7e0bd6256c6b06c2>" %}
{% 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/10-Teclado-Matricial-CCS-PIC18F4550-45K50/archive/refs/heads/main.zip">https://github.com/MICROSIDE-TECHNOLOGY/10-Teclado-Matricial-CCS-PIC18F4550-45K50/archive/refs/heads/main.zip</a></td></tr></tbody></table>
