Docsity

Embedded System Design - Introduction Microcontrollers | ECET 209, Lab Reports of Electrical and Electronics Engineering

Toggle sidebar
bg1
Purdue University Calumet Department of Electrical and Computer Engineering
Technology ECET 209 Embedded System Design
Lab 02
The code depicting reading input from RB0 and outputting the bits value
(it) to RB1.
/*
Lab 02
The code depicting reading input from RB0 and outputting the bits value (it) to RB1.
Designed by: Omer Farook
Jan 15th 2009
*/
#include <16f88.h>
//Header file for chip being used
//main body of program
void main (void)
{
/******************************************************************
* //sets portb of chip to 00000001 (RB0 is input all else output) *
******************************************************************/
set_tris_b(0x01);
//creates endless loop could also have been done with while (1)
start:
if (!input(pin_B0))
{
//if RB0 is 0, then only if icondition is true
//and then and then only make RB1 0
output_bit(pin_B1,0);
}
if (input(pin_B0))
{
//if RB0 is 1, then only if icondition is true
//and then and then only make RB1 1
output_bit(pin_B1,1);
}
goto start; //repeat loop at start
}

Partial preview of the text

Download Embedded System Design - Introduction Microcontrollers | ECET 209 and more Lab Reports Electrical and Electronics Engineering in PDF only on Docsity!

Purdue University Calumet Department of Electrical and Computer Engineering

Technology ECET 209 Embedded System Design

Lab 02

The code depicting reading input from RB0 and outputting the bits value

(it) to RB1.

Lab 02 The code depicting reading input from RB0 and outputting the bits value (it) to RB1. Designed by: Omer Farook Jan 15th 2009 */ #include <16f88.h> //Header file for chip being used

//main body of program void main (void) {

/******************************************************************

  • //sets portb of chip to 00000001 (RB0 is input all else output) * ******************************************************************/ set_tris_b(0x01);

//creates endless loop could also have been done with while (1) start: if (!input(pin_B0)) { //if RB0 is 0, then only if icondition is true //and then and then only make RB1 0 output_bit(pin_B1,0); }

if (input(pin_B0)) { //if RB0 is 1, then only if icondition is true //and then and then only make RB1 1 output_bit(pin_B1,1); }

goto start; //repeat loop at start }