Friday, June 7, 2013

Calculator with Assembly - PIC16F877

Detailed specifications of the program

Output
The result will be shown on the 7 segment display after entering number 1, number 2 and the operation.

Input
The input is taking from the keypad matrix based on PORTB by pressing on
1
2
3
4
5
6
7
8
9
*
0
#

Note:
  • You have to input 1st number then 2nd number then the operation
  • To input a number you have to enter it digit by digit then press #
  • Operations:
    • 1 represent sum ( + )
    • 2 represent subtract ( - )
    • 3 represent multiply ( * )
    • 4 represent divide ( / )
Program starts to enter number 1, when you hit "1" on the keypad now number 1 have "1".
Now hit "6" and number 1 will be "16"
To end editing in number 1 hit "#" and it will appear on the screen.

Now you have to enter number 2, hit "2" so number 2 is equal to "2".
Hit "#" to end editing and it will appear on the screen.

Now you have to enter the operation, hit "1" to sum the 2 numbers.



Now you have to enter the operation, hit "2" to subtract the 2 numbers.



Now you have to enter the operation, hit "3" to multiply the 2 numbers.


Now you have to enter the operation, hit "4" to divide the 2 numbers.


Program Properties


List of the used resources
  •  Laptop with windows platform.
  •  MPLAB X IDE v1.70 for developing.
  • PIC Simulator IDE for simulating PIC16F877 microcontroller.
    • Keypad Matrix
    • 7 Segment Display
  • PIC C Language.

Keypad Matrix configuration


7 Segment Display configuration


Download Code here.

Fibonacci Series with Assembly - PIC16F877

The first 21 Fibonacci numbers Fn for n = 0, 1, 2, ..., 20 are:
F0F1F2F3F4F5F6F7F8F9F10F11F12F13F14F15F16F17F18F19F20
011235813213455891442333776109871597258441816765
Check Fibonacci Series here.

Detailed specifications of the program

Input
The input is taking from the keypad matrix based on PORTB by pressing on
1
2
3
4
5
6
7
8
9
*
0
#

Note:
  • To input a number you have to enter it digit by digit then press #

Program starts to enter the index of the Fibonacci number you wish to end at it.
So if you enter 8, the program with output the first 8 Fibonacci numbers: 0, 1, 1, 2, 3, 5, 8, 13
When you hit "8" on the keypad now number have "8". To end editing in number hit "#" and the Fibonacci Series will appear on the display.

Output
The output can appear on 7 Segment Display based on PORTD(Data Port) & PORTA(Control Port).
The series will appeared with delay between them.








Program Properties


List of the used resources
  •  Laptop with windows platform.
  •  MPLAB X IDE v1.70 for developing.
  • PIC Simulator IDE for simulating PIC16F877 microcontroller.
    • Keypad Matrix
    • 7 Segment Display
  • PIC C Language.

Keypad Matrix configuration




7 Segment Display configuration




Download code here.

Merge Sort with C - PIC16F877


Detailed specifications of the program

Input
The input is taking from the keypad matrix based on PORTB by pressing on
1
2
3
4
5
6
7
8
9
*
0
#

Note:
  • Input 4 numbers (you can change it by changing the array size in the code).
  • To input a number you have to enter it digit by digit then press #

Program starts to enter number 1, when you hit "5" on the keypad now number 1 have "5". To end editing in number 1 hit "#" and it will appear on the screen.


Now you have to enter number 2, hit "6" so number 2 is equal to "6".
Now hit "6" again so number 2 is equal "66" now.
Hit "#" to end editing and it will appear on the screen.


Now you have to enter number 3, hit "1" so number 3 is equal to "1".
Now hit "9" so number 3 is equal "19" now.
Hit "#" to end editing and it will appear on the screen.


Now you have to enter number 4, hit "1" so number 4 is equal to "1".
Hit "#" to end editing and it will appear on the screen.



Output
The output can appear on 7 Segment Display based on PORTD(Data Port) & PORTA(Control Port).
The number will appeared sorted with delay between them.


Program Properties


List of the used resources
  •  Laptop with windows platform.
  •  MPLAB X IDE v1.70 for developing.
  • PIC Simulator IDE for simulating PIC16F877 microcontroller.
    • Keypad Matrix
    • 7 Segment Display
  • PIC C Language.

Keypad Matrix configuration



7 Segment Display configuration


Download code here.

Pexeso Game with C - PIC16F877

Detailed specifications of the game
Input
The input is taking from the keypad matrix based on PORTB by pressing on
1
2
Move Up
3
4
Move Left
5
Flip
6
Move Right
7
8
Move Down
9
*
Start new game
0
#
Quit

Output
The output can appear on (4x20) LCD based on PORTD & PORTC.
·         There is a screen for loading the game.
·         There is a selection frame to move on folded cards.
·         All cards have a question mark shape.
·         Having 20 different shapes to use.
·         There is a score count updates every time you get a score.
·         There is a clicks count updates every time you click on any card.
·         UI is some kind good and well organized.
Game Logic
These points are be handled
·         Cursor is moving to anywhere in LCD with the above instructions.
·         Selection frame is moving on fold cards and when flipping the shape must be appeared.
·         Able to compare upon selecting two – More than two is not a LOGIC.
·         When flip a folded card and flip it again, it turns to questions mark shape again.
·         When selecting two cards and they are not matches, they will be a question mark shape again.
·         When selecting two cards and they are matches, their cells will be empty.
·         At any time when pressing ‘*’, it will start a new game.
·         At any time when pressing ‘#’, it will quit the game.

Description of the implementation
  • Using only 0x00 to optimize the memory usage.
  • Using only unsigned integer 8 bit (uint8_t).
  • Implementing the LCD as points (x, y). So the game 20*2 means that the first row from point (0, 0) to (0, 19) and the second row from (1, 0) to (1, 19).
  • The code is well organized, divided into H files, commented.
  • Small memory use without using any extra memory.

Program Properties



List of the used resources
·         Laptop with windows platform.
·         MPLAB X IDE v1.70 for developing.
·         PIC Simulator IDE for simulating PIC16F877 microcontroller.
o   Keypad Matrix
o   4*20 LCD
·         PIC C Language.
Keypad Matrix configuration


LCD (4*20) configurations


Screenshots from the game:






Download Code here.