Question & Answer: The diagram above shows a 4 bit thumbwheel switch connected to PortC of an PIC18 microcontroller……

PIC 18 PORTC 4 bit binary value from PCO thumbwheel switch 0000-1001 for values 0-9 decimal Representing 00-90 degrees of PC3 angle in steps of 10. PC5 GND single LED indicator 10K 5V Normally open momentary push PC7 button switch GND

The diagram above shows a 4 bit thumbwheel switch connected to PortC of an PIC18 microcontroller. The wheel is used to dial up a number 0 – 9 representing an angle 00 – 90 degrees which is presented to the inputs as a 4 bit binary value. You are required to write a program and subroutines/functions to initialise and operate this interface.

Don't use plagiarized sources. Get Your Custom Essay on
Question & Answer: The diagram above shows a 4 bit thumbwheel switch connected to PortC of an PIC18 microcontroller……
GET AN ESSAY WRITTEN FOR YOU FROM AS LOW AS $13/PAGE
Order Essay

(i) Write a C subroutine to initialise PORTC as needed to interface with the devices.

(ii) Write a C function that checks if the push button is pressed or not, returning 1 if it is pressed or 0 if not pressed. This routine is not to wait for the press.

(iii) Write a C function that reads the thumb wheel switch, returning the angle. (Don’t forget there are other pins used on this port)

(iv) Write a C subroutine that sets the LED on or off given a value of 1 or 0. (Don’t forget there are other pins used on this port)

(v) Write a C main program that clears the LED, waits for the button to be pressed, sets the LED on, reads the angle set by the thumb wheel switch and saves that value in a variable called angle.

Expert Answer

 Question & Answer: The diagram above shows a 4 bit thumbwheel switch connected to PortC of an PIC18 microcontroller...... 1Question & Answer: The diagram above shows a 4 bit thumbwheel switch connected to PortC of an PIC18 microcontroller...... 2Question & Answer: The diagram above shows a 4 bit thumbwheel switch connected to PortC of an PIC18 microcontroller...... 3Question & Answer: The diagram above shows a 4 bit thumbwheel switch connected to PortC of an PIC18 microcontroller...... 4Question & Answer: The diagram above shows a 4 bit thumbwheel switch connected to PortC of an PIC18 microcontroller...... 5

Still stressed from student homework?
Get quality assistance from academic writers!