Question: I need help writing a program in C language. I have been assigned this but I only have background in Java therefore, I am struggling.

I need help writing a program in C language. I have been assigned this but I only have background in Java therefore, I am struggling.

Assignment :

Write a program that will input from a bank of 4 switches (DIP switches) and output each corresponding input to an equivalent LED. There would be a total of 4 LEDs. The input switches are connected from PORT A bits 0-3 while the output LEDs are tied to PORT C bits 0-3.

Hint: a) for PIC18F4620; study I/O Ports. Study the definitions of the TRISx registers where x represents the PORT name. Set the right value of each bit in the TRIS register to setup whether the corresponding pin is an input or output. A 1 will make the pin an input while a 0 makes it an output. Reading something from a switch to a pin of a port will make that pin an input. Controlling a LED from a pin of a port will make that pin an output. Based on those definitions, you should be able to determine what port should be setup as an input port or an output port. From there, you should be able to figure the value to be placed into the TRISx registers. In this case, you should deal with the registers TRISA and TRISC.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!