> For the complete documentation index, see [llms.txt](https://docs.microside.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.microside.com/practicas/pic-c-compiler-ccs/pic16f887-or-pic16f877a/9-teclado-matricial.md).

# 9 - Teclado Matricial

> **PIC C Compiler CCS**
>
> [**PIC16F887 / PIC16F877A**](https://docs.microside.com/practicas/pic-c-compiler-ccs/pic16f887-or-pic16f877a)

<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 **PIC16F887/PIC16F877A**. 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 **PIC16F887** o el **PIC16F877A**.
{% 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 **PIC16F877A/887**, 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-CCS-PIC16F887-877A/main/Diagrama%20de%20conexi%C3%B3n/X-TRAINER_Lite-M-r2_Practica-9_PIC16F_Microside_02.png" alt=""><figcaption></figcaption></figure>
{% endtab %}

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

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

{% tab title="LITE F" %}

<figure><img src="https://raw.githubusercontent.com/MICROSIDE-TECHNOLOGY/9-Keyboard-CCS-PIC16F887-877A/main/Diagrama%20de%20conexi%C3%B3n/X-TRAINER_Lite-F_Practica-9_PIC16F_Microside_02.png" alt=""><figcaption></figcaption></figure>
{% endtab %}

{% tab title="PRO R3" %}

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

{% tab title="PRO R4 " %}

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

## **Código**

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

{% tab title="PIC16F877A" %}
{% embed url="<https://gist.github.com/microside-mx/9aae33d18e42ad988fb937d75d6e25bd>" %}
{% 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-CCS-PIC16F887-877A/archive/refs/heads/main.zip">https://github.com/MICROSIDE-TECHNOLOGY/9-Keyboard-CCS-PIC16F887-877A/archive/refs/heads/main.zip</a></td></tr></tbody></table>
