PIC Microcontrollers: Q1 & Q2 Solutions

  • Thread starter Thread starter Frisky90
  • Start date Start date
AI Thread Summary
The discussion focuses on programming the PIC16F917A microcontroller to control LEDs using C language. The first question involves generating binary equivalents for the decimal numbers 119, 76, 14, 55, and 99 on port D. The second question addresses using a switch to read the status of bit 0 on port A, triggering odd-numbered LEDs on port D when the switch is closed. Participants seek guidance on the correct C syntax for reading and writing to these ports, as well as how to specify decimal and hexadecimal numbers in C. The conversation emphasizes the need for clear examples and syntax to assist those unfamiliar with C programming.
Frisky90
Messages
18
Reaction score
0
My question is related to PIC Microcontrollers.

Q 1
I have to use port D of the PIC16F917A as an output port and write a simple program to control 8 LEDS to generate the binary-equivalent of the following decimal numbers:

119, 76, 14, 55 & 99

I know how to convert the numbers, but I am not that familiar with the C language.

Q 2
Use a switch as an input to read the status of bit 0 of port A, write a program to switch all odd numbered LEDs (the most right hand LED is number 0) connected to port D, upon detecting the switch closure.
 
Physics news on Phys.org
Frisky90 said:
My question is related to PIC Microcontrollers.

Q 1
I have to use port D of the PIC16F917A as an output port and write a simple program to control 8 LEDS to generate the binary-equivalent of the following decimal numbers:

119, 76, 14, 55 & 99

I know how to convert the numbers, but I am not that familiar with the C language.

Q 2
Use a switch as an input to read the status of bit 0 of port A, write a program to switch all odd numbered LEDs (the most right hand LED is number 0) connected to port D, upon detecting the switch closure.

Could you show the syntax for reading and writing from those ports via C for the PIC?

Also, in C, you can specify if the number is decimal or Hexidecimal? Can you check your C book to see if you can find the syntax to use for the two different base designations?
 

Similar threads

Replies
1
Views
2K
Replies
7
Views
3K
Replies
13
Views
7K
2
Replies
97
Views
22K
Back
Top