PIC Microcontrollers: Q1 & Q2 Solutions

  • Thread starter Thread starter Frisky90
  • Start date Start date
Click For Summary
SUMMARY

This discussion focuses on programming the PIC16F917A microcontroller to control LEDs using C language. The user seeks to write a program that outputs binary equivalents of decimal numbers 119, 76, 14, 55, and 99 on port D. Additionally, the user inquires about using a switch to toggle odd-numbered LEDs based on the status of bit 0 of port A. The discussion emphasizes the need for specific C syntax for reading and writing to ports and differentiating between decimal and hexadecimal number representations.

PREREQUISITES
  • Understanding of PIC16F917A microcontroller architecture
  • Basic knowledge of C programming language
  • Familiarity with binary and hexadecimal number systems
  • Experience with microcontroller I/O port operations
NEXT STEPS
  • Research PIC16F917A I/O port programming in C
  • Learn about binary and hexadecimal number conversions in C
  • Explore switch input handling in embedded C programming
  • Study examples of LED control using PIC microcontrollers
USEFUL FOR

Embedded systems developers, electronics engineers, and students learning microcontroller programming, particularly those working with PIC microcontrollers and C language.

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 ·
Replies
1
Views
2K
  • · Replies 7 ·
Replies
7
Views
3K
  • · Replies 6 ·
Replies
6
Views
2K
  • · Replies 10 ·
Replies
10
Views
4K
  • · Replies 9 ·
Replies
9
Views
6K
  • · Replies 3 ·
Replies
3
Views
1K
  • Sticky
  • · Replies 13 ·
Replies
13
Views
8K
  • · Replies 11 ·
Replies
11
Views
4K
  • · Replies 97 ·
4
Replies
97
Views
24K
  • · Replies 11 ·
Replies
11
Views
6K