R

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 /*
00002 BEER PONG - STUDENT EDITION
00003 Rosemary Gillman
00004 ELEC2645 Project
00005 EL18RG
00006 **STUDENT NUMBER**
00007 */
00008 
00009 #include "mbed.h"
00010 #include "Gamepad.h"
00011 #include "N5110.h"
00012 
00013 Gamepad pad;
00014 N5110 lcd;
00015 
00016 int main()
00017 {
00018     lcd.init();                               //set the LED contrast
00019     lcd.setContrast(0.5);
00020     pad.init();
00021 
00022     lcd.backLightOn();
00023     lcd.printString("Beer Pong",15,2);          //display the game title
00024     lcd.printString("Leeds Edition",1,3);
00025     lcd.refresh();
00026     pad.tone(1000.0,2.0);                      //plays the bong tone
00027 
00028     for (int i = 0; i < 10; i++) {             //flash all the lights for 200 ms a pop
00029         pad.leds_on();
00030         wait_ms(200);
00031         pad.leds_off();
00032         wait_ms(200);
00033     }
00034     pad.leds_off();                             //turn off the flashing lights and the game title
00035     lcd.clear();
00036     lcd.refresh();    
00037     
00038     lcd.printString("Instructions:",0,0);       //display the instruction screen
00039     lcd.printString("Use joystick",0,1);
00040     lcd.printString("to aim.",0,2);
00041     lcd.printString("X to fire.",0,3);
00042     lcd.printString("Press start",0,4);
00043     lcd.printString("to go.",0,5);
00044     lcd.refresh();
00045     lcd.clear();
00046 
00047     }
00048