CODING (INSTRUCTIONS) IN C LANGUAGE
Coding is mostly made in C language ,,which is easy , but ; need much practice !!
Coding is nothing but instructions made by humans , which further get obeys by machine !!! The machine will works as per instructions , if it is not , then there is a problem in CODE i.e. instructions !!!
As an Engineer , You should be well aware of Coding ... The Coding , can be said as the language of communicating by human to machine !!!
Also we make this coding in KIEL software ..Once coding is completed we compile it and make a ".HEX" file ..this file further we load it on Michrocontroller by Flash Magic software !!!!
Now , Let us assume .. we are making code for the michro-controller shown below in Image..
Coding is nothing but instructions made by humans , which further get obeys by machine !!! The machine will works as per instructions , if it is not , then there is a problem in CODE i.e. instructions !!!
As an Engineer , You should be well aware of Coding ... The Coding , can be said as the language of communicating by human to machine !!!
Also we make this coding in KIEL software ..Once coding is completed we compile it and make a ".HEX" file ..this file further we load it on Michrocontroller by Flash Magic software !!!!
Now , Let us assume .. we are making code for the michro-controller shown below in Image..
In a michrocontroler , there a 4 ports (Let us count them as 0th,1st,2nd & 3rd for Our convenience )
We can declare any of these 4 ports as OUTPUT or INPUT ports !! In below example , we have declared 0th and 1st port as INPUT and 2nd port as OUTPUT , also in this case 3rd Port is unused .
We can declare any of these 4 ports as OUTPUT or INPUT ports !! In below example , we have declared 0th and 1st port as INPUT and 2nd port as OUTPUT , also in this case 3rd Port is unused .
CODE STRUCTURE
#include<p89v51rx2.h> /* Adding useful
#include<intrins.h> HEADER files */
/* By using 'sbit' we can name any pin of any port for our convenience...It can be done in following way......
sbit (name)=P(port no.)^(pin no,) */
sbit l_line=P1^0; // we are declaring 0th pin of 1st Port named as "l_line"
sbit r_line=P1^1; // we are declaring 1st pin of 1st Port named as "r_line"
sbit l_tsop=P1^2; // we are declaring 2nd pin of 1st Port named as "l_tsop"
sbit r_tsop=P1^3; // we are declaring 3rd pin of 1st Port named as "l_tsop"
sbit mic=P1^4; // we are declaring 4th pin of 1st Port named as "mic"
sbit ldr=P1^5; // we are declaring 5th pin of 1st Port named as "ldr"
//function for giving delay in milliseconds
void delay(unsigned int ms)
{
unsigned int i,j;
for(i=0;i<ms;i++)
for(i=0;i<ms;i++);
}
//main function
void main()
{
P0=0xff; // 0xff is used for input. (i.e. Here,we are declaring port this port as input.)
P1=0xff;
P2=0x00; // 0x00 is used for output . (i.e. Here,we are declaring this port as output.)
/* MAIN CODE HERE
Here .. we can have many codes as our desire .... This is depends on us ,that is on what kind of task or operation we want to perform by robot
*/
}
Examples of Different Types of Codes
In The video , we can see the 10 types of Operations we are performing ...
RC CAR WHITE LINE FOLLOWER BLACK LINE FOLLOWER OBSTACLE AVOIDER OBSTACLE FOLLOWER SOUND RUN SOUND STOP PHOTO TROPIC PHOTO PHOBIC WALL FOLLOWER |
RC CAR
|
WALL FOLLOWER
|
WHITE LINE FOLLOWER
|
BLACK LINE FOLLOWER
|
OBSTACLE AVOIDER
|
OBSTACLE FOLLOWER
|
SOUND RUN
|
SOUND STOP
|
PHOTO TROPIC
|
PHOTO PHOBIC
|