Skip to main content

First of all you need to configure your input and output correctly.

You used TRISA = 1;TRISA = 1; which means only RA0 is an INPUT. Please change this to "TRISA = 0b00000111;"TRISA = 0b00000111; or "TRISA = 0x07;TRISA = 0x07; to configure all 3 buttons as INPUT.

Same counts for TRISB. Change this value to 0x00000111 or 0x07.

As Peter has mentioned change all your cases on the switch to:

case1: // TODO return; case2: // TODO return;

case1:
 // TODO
 return;
case2:
 // TODO
 return;

Besides, I don't even see where you scripted what the MCU has to do when a button is pressed?

First of all you need to configure your input and output correctly.

You used TRISA = 1; which means only RA0 is an INPUT. Please change this to "TRISA = 0b00000111;" or "TRISA = 0x07; to configure all 3 buttons as INPUT.

Same counts for TRISB. Change this value to 0x00000111 or 0x07.

As Peter has mentioned change all your cases on the switch to:

case1: // TODO return; case2: // TODO return;

Besides, I don't even see where you scripted what the MCU has to do when a button is pressed?

First of all you need to configure your input and output correctly.

You used TRISA = 1; which means only RA0 is an INPUT. Please change this to TRISA = 0b00000111; or TRISA = 0x07; to configure all 3 buttons as INPUT.

Same counts for TRISB. Change this value to 0x00000111 or 0x07.

As Peter has mentioned change all your cases on the switch to:

case1:
 // TODO
 return;
case2:
 // TODO
 return;

Besides, I don't even see where you scripted what the MCU has to do when a button is pressed?

added 2 characters in body
Source Link
Handoko
  • 445
  • 2
  • 11

First of all you need to configure your input and output correctly.

You used TRISA = 1; which means only RA0 is an INPUT. Please change this to "TRISA = 0b00000111;" or "TRISA = 0x07; to configure all 3 buttons as INPUT.

Same counts for TRISB. Change this value to 0x00000111 or 0x07.

As Peter has mentioned change all your cases on the switch to:

case1: // TODO break;return; case2: // TODO break;return;

Besides, I don't even see where you scripted what the MCU has to do when a button is pressed?

First of all you need to configure your input and output correctly.

You used TRISA = 1; which means only RA0 is an INPUT. Please change this to "TRISA = 0b00000111;" or "TRISA = 0x07; to configure all 3 buttons as INPUT.

Same counts for TRISB. Change this value to 0x00000111 or 0x07.

As Peter has mentioned change all your cases on the switch to:

case1: // TODO break; case2: // TODO break;

Besides, I don't even see where you scripted what the MCU has to do when a button is pressed?

First of all you need to configure your input and output correctly.

You used TRISA = 1; which means only RA0 is an INPUT. Please change this to "TRISA = 0b00000111;" or "TRISA = 0x07; to configure all 3 buttons as INPUT.

Same counts for TRISB. Change this value to 0x00000111 or 0x07.

As Peter has mentioned change all your cases on the switch to:

case1: // TODO return; case2: // TODO return;

Besides, I don't even see where you scripted what the MCU has to do when a button is pressed?

Source Link
Handoko
  • 445
  • 2
  • 11

First of all you need to configure your input and output correctly.

You used TRISA = 1; which means only RA0 is an INPUT. Please change this to "TRISA = 0b00000111;" or "TRISA = 0x07; to configure all 3 buttons as INPUT.

Same counts for TRISB. Change this value to 0x00000111 or 0x07.

As Peter has mentioned change all your cases on the switch to:

case1: // TODO break; case2: // TODO break;

Besides, I don't even see where you scripted what the MCU has to do when a button is pressed?