brock

Monday, November 19, 2012

Intelligent Traffic Lights Based on RFID


Activity administration is the basic issue of the street. Movement lights play an imperative part in the activity administration. The existing activity lights accompany the decided ahead of time arrangement. So the aforementioned lights are called static activity lights. The aforementioned activity lights are not skilled to check the number of vehicles and the necessity of the vehicles on crossing point indicate. Therefore certain vehicles need to hold up even there is no movement on the different side. The vehicles such as Emergency vehicle and Fiery breakout Detachment are in addition stayed in movement and waste their valuable time. The recommended framework gives value of aid to Crisis vehicles and enhances the exactness of Programmed Activity Light Violation Location framework and additionally causes to follow out the taken vehicles utilizing RFID. The streets convergence is a bottleneck indicate in the urban activity system and its exceptionally discriminating junction. Activity may amass instantly and activity driving conditions can happen briskly in the event that the movement Universal Diary of Figuring & Business Research ISSN (Connected): 2229-6166 Incidents of ‘I-Publicly accepted norms 2012’ at GKU, Talwandi Sabo Bathinda (Punjab ) control framework is not productive to fittingly administer the vehicles queues in quick and sharp manner.A sharp activity control framework dependent upon the satellite sensor grid and a cautioning framework for red light intersection situation to caution the drivers on different sides to recovery their lives. This procedure is dependent upon the queue length of the vehicles on the movement lights. They in addition act for the recreation of 4 models which are utilized as a part of the distinctive parts of the globe and shows contending consequences in the terms of holding up time and number of vehicles not served first time. This is a methodology to coordinate Satellite Sensor Arrangement (WSN) in the RFID Book fan to bring about transport administration framework where movement sensors are utilized to send charge to the RFID book fan to drop in the read when it catches the RFID tag development around it then after that RFID Bookworm peruses the substance of RFID tag and go this informative content to accommodate provision by means of IEEE 802.15.4/Zigbee standard, that diminishes the expense and time by killing the wired introduction of link . Here they likewise look at Bluetooth and Zigbee method for satellite correspondence. Every convergence holds 8 RFID book lovers. The street is separated into two paths. Every path has its RFID followers to track the vehicles passing through it. Every crossing point indicate has its particular database to archive the qualified data observing the vehicles that sat back stamp and activity light. Each vehicle has a RFID prepared gadget that stores a vehicle recognizable proof number (VIN). Each vehicle has its special VIN number that furnishes the qualified data noticing the necessity of the vehicle and sort of the vehicle. With the assistance of VIN we can remarkably recognize the vehicle & its possessor. Vehicle ID Number: In the recommended work RFID, tag will store a Vehicle Recognizable proof Number. This number is partitioned into 3 parts: First part act for the necessity of the vehicles. Afterward part stands for the sort of vehicle and subsequently digits stand for the vehicle number. Necessity: In the suggested work, diverse sorts of vehicles have the special necessities. The sum vehicles are partitioned into 4 classes: First framework classification incorporates Rescue vehicle, Fiery breakout Detachment vehicles and V.I.P vehicles. These vehicles have the most astounding necessity. The second class incorporates the transports and school & school transports. The aforementioned transports ought to achieve their objective on time so the aforementioned vehicles moreover need a snappy utility. Third class incorporates the auto, engine cycles and bikes and fourth classification incorporate the Huge vehicles. Day time necessity Global Diary of Processing & Business Research ISSN (Connected): 2229-6166 Processes of ‘I-Social order 2012’ at GKU, Talwandi Sabo Bathinda (Punjab) of 3rd classification is elevated as contrast with 4th classification but around night hours the necessity of the large vehicles towering. Every crossing point on the way has 4 movement lights as demonstrated in the figure 1. Every path has its particular RFID book fan that stores the vehicles sitting back stamp. On the foundation of the time stamp, we discover the violators. For this reason we store the term of the green light. So the vehicles going ahead the relating light are permitted to move in any course. Around this time book lover relating to red light stores the vehicles passing through the path. 
Intelligent Movement Light Controller: Every city has different crossing points as indicated in the figure 2. Two lights are called joined Lights that are put on inverse sides of the street that unite two crossing points. The RFID book fan stores the records of every last trace of the vehicles that passed through the street. The Activity light controller accompanies the same adjust robin succession of the lights. In any case if a Crisis vehicle is recognized at any movement light then controller leave the round robin plan and create the green indicator for the emergency vehicle. The different assignment of the controller is to figure the time of green sign that is dependent upon the number of vehicle. To take care of the situation of Starvation a time utmost is characterized. In the event that this point of confinement overtakes then that light gets its turn. 
Pseudo code for Traffic light control: The emulating given pseudo code encourages to produce a productive contrivance to control the arrangement of the movement light concurring the parameters examined previously. 
While (true)
1. Store all lights in Queue
2. Sense the vehicles on different lights continuously
3. If a high priority vehicle is detected then
a. Send an emergency signal to center Traffic light controller
b. Find the road corresponding to the reader that detect a high priority vehicle
c. Set the corresponding traffic light Green
4. Else
5. For i=1 to 4
a. At decision point dp Pick the traffic light Queue[i]
a. At traffic i Count the number of vehicles & check type of vehicle
b. If Emergency vehicle found then
1. Go to step 3
c. Else follow steps d to f
d. Find the priority of the different vehicle at traffic light i
e. Calculate the total sum according to Number of vehicle
f. On the basis of sum calculate the time for green signal
g. If any light doesn't get it term within the threshold time then
1. Give the turn to that light
6. End Loop
7. End

 Here the essential motivation behind the contrivance is to ascertain the green time length of time and likewise give the value of the aid to the Crisis vehicles like emergency vehicle, Blaze unit and VIP vehicles with the goal that they can get to at their terminus as right on time would be prudent and decrease the time squandered at the Red Light. 


Thursday, November 15, 2012

Electronic code lock using 8051 microcontroller


A 4x3 framework keypad and a 16x2 LCD have been utilized here. Keypad and LCD are exceptionally regularly utilized enter & yield units, separately. A four digit predefined watchword should be specified the user. This secret word is saved in the framework. 

While unlocking, if the dropped in watchword from keypad matches with the archived secret key, then the lock opens and a note is shown on LCD. Moreover a yield bind is made elevated to be utilized for further reason. 

The associations in the circuit are as taking after: port P2 of microcontroller AT89C51 is utilized as information include port which is joined with information binds (7-14) of LCD. P1^0, P1^1 and P1^2 binds of microcontroller are joined with control binds RS, RW and EN of LCD. Port P0 is utilized to take include from keypad. P0^7 has been utilized as lock yield bind of controller. 



As the project begins, string ‘Enter Password’ is shown on LCD. The keypad is checked for pressed digits one by one. Unfailingly, column and section of the nexus pressed is located and a ‘*’ is shown on LCD relating to the dropped in number. When the four digits are dropped in, the user is incited to ‘Confirm Password’ and again the info is taken through LCD. Depending on if the passwords don't match, a note is shown to demonstrate ‘Wrong Password’; generally the user is incited to unlock the apparatus. 


To unlock, user should ‘Enter Password’ through keypad. Again the keypad is examined for pressed keys and comparing digits are distinguished. The passkey is shown as ‘****’ on the LCD screen. When the four digits are dropped in, they are contrasted and the pre-set watchword. Provided that every last trace of the four digits match with set watchword, LCD presentations ‘Lock Open’ and the lock yield bind goes elevated. Depending on if the security code is wrong, ‘Wrong Password’ is sent to be shown on LCD. The framework inches toward getting bolted if more than several endeavors are made with wrong secret key to open the electronic bolt. The framework should be reset in quite an impressive case. 



Parking Gate Control Using IR


Infrared technology is highlighted because of its increasing presence in mainstream applications, its current and potential usage in disability-related applications, and its advantages over other forms of wireless communication as depicted in Fig. 1, infrared radiation is the region of the electromagnetic spectrum between microwaves and visible light. In infrared communication an LED transmits the infrared signal as bursts of non-visible light. At the receiving end a photodiode or photoreceptor detects and captures the light pulses, which are then processed to retrieve the information they contain. Some of the common applications of infrared technology were listed as shown below:
            Infrared technology offers several important advantages as a form of wireless communication. Advantages and disadvantages of IR are first presented, followed by a comparative listing of radio frequency (RF) advantages and disadvantages.
  1. Augmentative communication devices
  2. Car locking systems
  3. Computers
    a. Mouse          b. Keyboards   c. Floppy disk drives               d. Printers
  4. Emergency response systems
  5. Environmental control systems
    a. Windows     b. Doors          c. Lights          d. Curtains      e. Beds                        f. Radios
  6. Headphones
  7. Home security systems
  8. Navigation systems
  9. Signage
  10. Telephones
  11. TVs, VCRs, CD players, stereos
  12. Toys

IR Advantages:

  1. Low power requirements: therefore ideal for laptops, telephones, personal digital assistants
  2. Low circuitry costs: $2-$5 for the entire coding/decoding circuitry
  3. Simple circuitry: no special or proprietary hardware is required, can be incorporated into the integrated circuit of a product
  4. Higher security: directionality of the beam helps ensure that data isn't leaked or spilled to nearby devices as it's transmitted
  5. Portable
  6. Few international regulatory constraints: IrDA (Infrared Data Association) functional devices will ideally be usable by international travelers, no matter where they may be
  7. High noise immunity: not as likely to have interference from signals from other devices


Wednesday, November 14, 2012

IR Based Home Automation


We are operating the home appliances by using an IR remote which is interfaced with the microcontroller by using various components.
            A 12v power supply is generated and it is supplied to the micro controller by using a transformer. Atmel microcontroller based hardware is used along with real time clock interface. The development involves writing the software code for microcontroller at which the automation can be done. The microcontroller based hardware is chosen to implement this concept. The loads like lights, motors, heaters, power controlling system and also current through the loads can be controlled in this project. We can control all loads at a time from one place (control room) without connecting any physical wire between loads and control room.
Since AC loads are also controlled in this project and the microcontroller cannot handle AC loads, TRIAC is used to control the AC loads. The speed of AC motor can be varied rapidly on and off by TRIAC. The main advantage of using a TRIAC to vary the speed of an AC motor is the TRIAC reduces the energy flow to the motor and TRIAC works very well for alternating currents. Hence, in our module we use the TSOP 1738 IR receiver, MOC 3021 TRIAC, IR remote controller, crystal oscillator and some other related equipment. Crystal oscillator is used to generate a frequency of 11.0592MHz. Two load capacitors of 33 pF are used to eliminate the noise which is occurred in the oscillator. For reset button we used one pull up switch which is connected to reset pin of micro controller. An IR remote control device uses IR light which is invisible light about 950nm wavelength. One biggest problem in using IR light is that there many other sources of it like sun, light bulbs, fire. In order to exclude other sources, IR signal is modulated by some frequency. Receiver has to be tuned for this frequency. Mostly remote controls transmit IR signal using 36 kHz frequency signals. Here in our module we are using TSOP1738 IR receiver which generates the frequency of 38 kHz, exactly matched with our remote controller.
            Thus, we can control (i.e., switch on/off) the home appliances by using an IR remote which is interfaced with microcontroller.
CODE:

Friday, November 2, 2012

Low Cost 500W 12V To 220V Inverter Circuit

Using this circuit you can convert the 12V dc in to the 220V Ac. In this circuit 4047 is use to generate the square wave of 50hz and amplify the current and then amplify the voltage by using the step transformer.

How to calculate transformer rating

The basic formula is P=VI and between input output of the transformer we have Power input = Power output. For example if we want a 220W output at 220V then we need 1A at the output. Then at the input we must have at least 18.3V at 12V because: 12V*18.3 = 220v*1
So you have to wind the step up transformer 12v to 220v but input winding must be capable to bear 20A.

Attention: This Circuit is using high voltage that is lethal. Please take appropriate precautions

White LED Lamp Circuit

Nowadays you can buy white LEDs, which emit quite a bit of light. They are so bright that you shouldn’t look directly at them. They are still expensive, but that is bound to change. You can make a very good solid-state pocket torch using a few of these white LEDs. The simplest approach is naturally to use a separate series resistor for each LED, which has an operating voltage of around 3.5 V at 20 mA. Depending on the value of the supply voltage, quite a bit of power will be lost in the resistors. The converter shown here generates a voltage that is high enough to allow ten LEDs to be connected in series.
In addition, this converter supplies a constant current instead of a constant voltage.
Resistors: R1 = 1kΩ2 R2 = 68Ω Capacitors: C1 = 100µF 16V radial C2 = 680nF C3 = 100µF 63V radial Inductors: L1 = 200µH 1A Semiconductors: D1 = Schottky diode type PBYR745 or equivalent D2-D5 = zener diode 10V, 0.4W D6-D15 = white LED IC1 = LM2585T-ADJ (National Semiconductor)

Thursday, November 1, 2012

Introduction to C and the PIC Microcontroller ( C for PIC )


In this tutorial you will be introduced to the programming language C, and the PIC16F873, a popular and very widely used m-controller (read micro-controller). m-controllers find use in devices that needs some intelligence but not a huge amount of processing power (eg, fancy graphical interfaces, massive computing needs). You can find these devices in cars (engine control, anti-lock brakes...), in appliances, etc... There are many ways to program these devices, but you will be using C to program the PIC to perform some fairly simple tasks. C is often used with m-controllers because of its small size, high speed, and the access it allows to the real-world. This week you will get a short introduction to C as well as a brief look at some of the capabilities of the PIC.
A good resource for help with the PIC programmed with the CCS C-compiler is given at http://www.ccsinfo.com/forum/.
The PIC microcontroller comes in a wide range of variants.  You can check them out in data books that are in the lab, or at the MicroChip web site.  A m-controller is distinguished from a m-processor in that it has many capabilities useful for real-world interfacing built into the chip.  The PIC has a RISC-based Harvard architecture with separate memory for data and program.  The one we will be using is the PIC16F873  (link to data sheet)   It has an on-board RAM (Random Access Memory), EPROM (Erasable Programmable Read Only Memory), an oscillator, a couple of timers, and several Input/Output (I/O) pins, serial ports and 8 channel A/D convertor (if you don’t know what all of those things are don’t worry; suffice it to say there can be an impressive array of peripherals built into the chip). However, the m-controller is less computationally capable than mostm-processors due to the fact that they are used for simple control applications rather than spreadsheets and elaborate calculations. As an example, the PIC16F873 has 4096 words of memory for program, and only 192 bytes of RAM, and can only operate with clocks up to 20 MHz on 8 bits of data (compared to megabytes of RAM, Speeds of a GHZ or more and 32 or even 64 bits of data for many desktop systems).  It also has no facilities for floating point numbers... A pinout of the PIC16F873 is shown below.


There are several pins that are used to power the device.   Many of the other pins have multiple uses depending on how the device is programmed. 
This week, and the next, you will be using a m-controller in the lab. These laboratories will serve as a brief introduction to the processor and to programming in C.

Getting started with C.
A simple C program
A very simple C program is shown below.
/*simple.c -- sets a pin low, then high*/
#INCLUDE <16f873 .h=".h">
#USE DELAY (CLOCK=4000000)
void main() {

        output_low(pin_C1);
        output_high(pin_C1);
}
This program has many common features of C programs. The first line is a comment that is ignored by the compiler.  It is simply there to document what the program code does.  A comment is anything that occurs between a "/*" and the subsequent "*/".  The next line is a "directive".  All directives begin with a "#" and are used to convey information to the compiler.   The directive in this program tells the compiler to include a header file ("16F873.h") which is necessary when using the microcontroller’s input and output capabilities.   The next two directives tell it how to configure the device, and how fast it goes.  The next line tells the compiler that this is the "main" program, and that everything between the opening brace, {, and the matching closing brace, , constitutes the main program. The main program itself is only two lines.   The first  line (not a comment) is a call to the "output_low" function, which sets output pin pin_C1 low, and a call to output_high, which sets it high. . Note that after every program statement there is a semi-colon. This is very important.

Variables
Almost all programs will use variables which are simply units of information stored in the computers memory. The standard C language has a wide variety of variable types available, however the dialect we will be using is more restricted. The version of C that we will be using has a quite unstandard set of variable types that are suited to its architecture.
Type Specifier
Size
Range
unsigned
8 bit unsigned
0 to 255
unsigned int
int
char
int8
long
16 bit unsigned
0 to 65535
long int
int16
signed
8 bit signed
-128 to 127
signed int
signed int8
signed long
16 bit signed
-32768
to 32767
signed int8
int32
32 bit unsigned
4*109
signed int32
32 bit signed
±2*109
float
32 bit floating point
±0.5*2-128 to 1-(2-15)*2128
short
one bit
0 to 1
short int
int1
The program below shows how variables are used.
#INCLUDE <16f873 .h=".h">
#USE DELAY (CLOCK=4000000)
void main() {
   char i, j, k; /* declare characters */
    i=2;
    j=3;
    k=i+j;
}
Again we have a fairly simple program that shows many different features of C. Note the semicolon after every program statement. We declare 3 char’s, "i", "j" and "k".   A char is simply an 8 bit variable.  You should use chars whenever possible because the PIC is designed to work on data 8 bits at a time.

Numerical manipulations
C has a variety of built in operations for performing math. These are listed below along with an example where a=0x03, and b=0x11:

Name of Operand
Symbol
Example
Result a=0x03 b=0x11
Binary Operators (Two Operands)
Addition
+
a+b
0x14
Subtraction
-
b-a
0x0E
Multiplication
*
a*b
0x33
Division
/
b/a
0x05
Modulus
(remainder)
%
b%a
0x02
Bitwise and
&
b&a
0x01
Bitwise or
|
b|a
0x13
Bitwise xor
^
b^a
0x12
Shift right
>> 
b>>a
0x02
Shift left
<< 
b<
0x88
Unary Operators (One Operand)
increment
++
++a
0x04
decrement
--
--a
0x03
negate
-
-a
-0x03
logical complement
~
~a
0xFC

Logical Expressions
In addition ot manipulating numbers, C is also capable of handling logical expressions. When using these expressions TRUE is taken to be anything that is not zero, and FALSE is always equal to zero. Again, a=0x03, and b=0x11:
Binary operators (two operands)
Name of Operand
Symbol
Example
Result
a=0x03 b=0x11
Binary Operators
Greater than
> 
a>b
FALSE
Less than
< 
a
TRUE
Equal
==
a==b
FALSE
Greater than or equal
>=
a>=b
FALSE
Less than or equal
<=
a<=b
TRUE
Not equal
!=
a!=b
TRUE
Logical AND
&&
a&&b
TRUE
Logical OR
||
a||b
TRUE
Unary operators (one operand)
Logical complement
!
!a
FALSE


Manipulating addresses (somewhat advanced topic, may be skipped)
There are two operators used for manipulating addresses and you have already been briefly introduced to one of them, the indirection operator, *. The other one is the address operator &. If you have an address k, the value stored at that address is *k. If you have a variable j, the address of the variable is given by &j. Therefore it is obvious that *(&j)=j.

I/O (Input/Output) Ports
It is possible with with a PIC to interact with the real world.   This is done thourgh the use of I/O ports.  The PIC16F873 has 3 I/O ports, labeled "a", "b" and "c".  We will use Port A for analog input, though it has other uses. Ports B and C will be used for digital I/O.  On the schematic the pins are labeled RB0 through RB7, but the compiler refers to them as pin_B0 through pin_B7.   Likewise for port C.  The pins can be used for either input or output. 
Your circuit has the pushbutton switch connected to RB0, and the LED's to pins RC0 through RC7.
Digital Output
There are several functions that are used for output from the PIC.   A full listing is in the PCB manual.  Four commonly used functions are:
·         Output_high(pin)
Sets the specified pin to a logic 1 (about 5 volts).
·         Output_low(pin)
Sets the specified pin to a logic 0 (about 0 volts)
·         Output_float(pin)
Sets the specified pin to a high-impedance (or tri-state) state.  In this state it is as if the pin has no connections to the chip.  Current can neither go in or out of the pin.
·         Output_bit(pin, value)
This function sets the specified pin to the specified value (which must be 0 or 1).
Digital Input
There is only one input function you will need for the PIC.
·         Input(pin)
Reads the value on a specified pin.  The value is returned in a short int.   A proper use of the function would be something like:

    while( !input(pin_B0)) { ... }

which would repeat the commands in the braces as long as RB0 was low.
"High level" I/O
If the PIC is connected to the PIC C development software via the debugger it is possible to do some higher level input and output.  These  interactions take place via the debugger's "Monitor" window.
You specify that IO is to take place through the debugger by properly defining serial connections (usually in your codes header file):
#use rs232(DEBUGGER)
You can then print to the monitor window by using "putc()" which sends a character to the monitor window, "puts()" which sends a string, or "printf()" which sends a formatted string.  The "printf()" command is most useful, but also the most complicated (and takes the most memory).
The syntax of printf is the following:
printf(format-string, [arg_1] , ... , [arg_N] )
This is best illustrated by some examples.
Example 1: Printing a message. The following statement prints a text string to the screen.
printf("Hello, world!\n");
In this example, the format string is simply printed to the screen.
The character \n at the end of the string signifies end-of-line. When an end-of-line character is printed, the LCD screen will be cleared when a subsequent character is printed. Thus, most printfstatements are terminated by a \n.
Example 2: Printing a number. The following statement prints the value of the integer variable x with a brief message.
printf("Value is %d\n", x);
The special form %d is used to format the printing of an integer in decimal format.
Example 3: Printing a character. The following statement prints the ascii equivalent of the integer variable x with a brief message.  
printf("Value is %d, ascii = %c\n", x, x);
Example 4: Printing a number in binary. The following statement prints the value of the integer variable x as a binary number.
printf("Value is %b\n", x);
The special form %b is used to format the printing of an integer in binary format. Only the low byte of the number is printed.
Example 5: Printing a floating point number. The following statement prints the value of the floating point variable n as a floating point number.
printf("Value is %f\n", n);
The special form %f is used to format the printing of floating point number.
Example 6: Printing two numbers in hexadecimal format.
printf("A=%x  B=%x\n", a, b);
The form %x formats an integer to print in hexadecimal.
%d
Type: int Description: decimal number
%x
Type: int Description: hexadecimal number
%b
Type: int Description: low byte as binary number
%c
Type: int Description: low byte as ASCII character
%f
Type: float Description: floating point number
%s
Type: char array Description: char array (string)
Format Command
Data Type
Description
%d
int
decimal number
%x
int
hexadecimal number
%b
int
low byte as binary number
%c
int
low byte as ASCII character
%f
float
floating point number
%s
char array
char array (string)

Your circuit has the pushbutton switch connected to RB0, and the LED's to pins RC0 through RC7.
Input
Unfortunately, you can only receive input from the keyboard one character at a time using the getc() command.  Be aware:
·         getc() returns the ascii equivalent of the character entered into the keyboard.
·         the keyboard I/O is implemented in software on the PIC.  That means, it won't receive input from the keyboard unless it is explicitly looking for it.  Therefore, your program must stop in order to look for input from the keyboard.  (Hardware communications could receive a character in the background, without requiring software support).
As an example, the following code gets the ascii value in k, converts to a number, and prints the number.
k=getc();                %Get ascii value of keyboard input.
k=k-'0';                 %Subtract value of '0' to convert to number.
printf(" ... k=%d\n",k); %print the number.
Control of Flow
What you have learned up to this point has been useful but is of limited utility because it does not allow for decision making capabilities by the computer. C has a variety of mechanisms to control the flow of a program. These are listed below:
The if...then construct
if (logical expression) {
    ...statements...
}
If the logical expression is true then evaluate the statements between the braces. The following code sets RC1 if a is even.
if ((a%2) == 0) {
   Output_high(pin_C1);
}
The if...then...else construct
if (logical expression) {
   ...if statements...
}
else {
   ...else statements...
}
If the logical expression is true then evaluate the "if" statements between the braces, otherwise execute the "else" statements. The following code decides if a number if is even or odd.
if ((a%2) == 0) {
   Output_high(pin_C1);
}
else {
   Output_low(pin_C1);
}
while (logical expression) {
    ...statements...
}
While the logical expression is true, the statments (of which there is an arbitrary number) between the braces is executed. The following code cycles through the even numbers from 0 to 9 (the variables must have been declared elsewhere in the program).
a=0;
while (a<10 o:p="o:p">
    ...statements...
    a=a+2;
}

The for loop
for (initial condition; logical expression; change loop counter variable) {
    ...statements...
}
Set the initial condition, then while the logical expression is true execute the statement between the braces while changing the loop counter as specified once at the end of each loop. This code segment is functionally equivalent to the one for the "while" loop.
for (a=0; a<10 a="a+2)" br="br">     ...statements...
}

The case...switch construct
Case..switch is used in place of a series of "if...else" clauses when a variable can take on several values.  The "default" clause at the bottom takes care of any cases not covered explicitly.
switch (variable) {
   case val1: ...statements 1...
   break;
   case val2: ...statements 2...
   break;
   case val3: ...statements 3...
   break;
   default: ...statements default...
   break;
}

Functions
Often a series of instruction must be repeated over and over again. Instead of repeating the same operations repetitively it is useful to use a function that performs the repetitive operations. For instance to set a value on RC1 and then read from RB0 and set RC0 to that value, and returning the value of RB0 you might use a function called "RB0toRC0".  (Note: this program isn't meant to be particularly useful, but to introduce the syntax for function declaration, and use).
/*simpleFunc.c -- to demonstrate function calls*/
#INCLUDE <16f873 .h=".h">
#USE DELAY (CLOCK=4000000)
short int RB0toRC0(RC1val)
short int RC1val;
{
   Output_bit(pin_C1, RC1val);  /*Set RC1 to the specified value*/
   if (input(pin_B0)) {         /*Read RB0*/     
      Output_high(pin_C0);      /*If RB0 is high, RC0 set high*/
   }
   else {
      Output_low(pin_C0);       /*else set RC0 low*/
   }
   return(input(pin_B0));       /*Return RB0*/
}
void main() {
   short int b;

   b=RB0toRC0(1);
   b=RB0toRC0(0);
}
This program introduces some new constructs. The most obvious is the function "RB0toRC0" which is at the top. The first line of the function declares that the function returns a short int, and has one argument. The type of the argument is given before the function's opening brace. The body of the function (between the braces) outputs a value to RC1, and reads from RB0 and echos to RC1.  The last line tells that compiler to return the value of RB0 to the calling function.
The function is called in the main program with different arguments.   The first call would set RC1 high, and return the current value of RB0 to the variable "b".  The next line would set RC1 low, and return the value of RB0 to the variable "b".
Wrapping up
You should now know enough to do some fairly simple things with the microcontroller. This has been a very brief introduction to C and did not even begin to touch the richness available with the language. If you would like to know more look in the manuals in the lab, or some of the books in the library.