slide1 n.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
#include < plib.h > #include "CerebotMX7cK.h" #include "Project1.h" int main() { PowerPoint Presentation
Download Presentation
#include < plib.h > #include "CerebotMX7cK.h" #include "Project1.h" int main() {

Loading in 2 Seconds...

play fullscreen
1 / 5

#include < plib.h > #include "CerebotMX7cK.h" #include "Project1.h" int main() { - PowerPoint PPT Presentation


  • 279 Views
  • Uploaded on

#include < plib.h > #include "CerebotMX7cK.h" #include "Project1.h" int main() { unsigned int buttons, leds ; initialize_system (); while(1) { buttons= read_buttons (); leds = decode_buttons (buttons); control_leds ( leds ); } // while(1) return 1;

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about '#include < plib.h > #include "CerebotMX7cK.h" #include "Project1.h" int main() {' - shay-farmer


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
slide1

#include <plib.h>

#include "CerebotMX7cK.h"

#include "Project1.h"

int main()

{

unsigned int buttons, leds;

initialize_system();

while(1)

{

buttons=read_buttons();

leds=decode_buttons(buttons);

control_leds(leds);

} // while(1)

return 1;

} // main

what to include
What to include!?!?!
  • Header files have definitions and function prototypes
  • Include the header file if you want to use a definition or function from the file
  • Never include .c files!!!
  • Never include config_bits.h (it is included by CerebotMX7ck.c)
  • Don’t change CerebotMX7ck .h or .c files
  • Instead, create your own project[#].h file
  • Include CerebotMX7ch.h and plib.h in your project[#].c file
read buttons
read_buttons()

intread_buttons(void)

{

// return (PORTReadBits(IOPORT_G, BTN1 | BTN2));

return(PORTG & (BTN1 | BTN2));

} // read_buttons

decode buttons
decode_buttons()

intdecode_buttons(int buttons)

{

unsigned intleds=0; // could of intializedto LED1

switch (buttons) {

case BTN1 :

leds=LED2;

break;

case BTN2:

leds=LED3;

break;

case BTN1 | BTN2 :

leds=LED4;

break;

default : // no buttons

leds=LED1;

break;

} // case

return(leds);

} // decode_buttons

control leds
control_leds()

void control_leds(intleds)

{

// PORTWrite(IOPORT_G, leds);

LATG=leds;

} // control_leds