SIMON WORKING CODE - #include "msp430x44x.h"...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
Sheet1 Page 1 #include "msp430x44x.h" // Definitions, constants, etc for msp430F449 #include <string.h> #include <stdio.h> #include <stdlib.h> #include <math.h> #include <in430.h> // ***************************************** FUNCTION DECLARATIONS ************************************************** void init_sys(void) void setupKeypad(void) void getKeys(void) void swDelay(unsigned int max_cnt) void clearLCD(void) void initLCD(void) void writeLetter(int position,char letter) void writeWord(const char *word) // also display numbers passed as text void buzzerOn(void) void buzzerOff(void) void LEDOff(void) void LEDdisplayHex(unsigned char num) void waitGetKeys(void) /************************************************************************/ /* */ /* Global variable declarations */ /* */ /************************************************************************/ char *LCD = LCDMEM unsigned char hitKey=0 /************************************************************************/ /* */ /* main() variable declarations */ /* */ /************************************************************************/ //******************************************** LCD CONSTANTS ******************************************************** // From Muneem Shahriar's LCD driver code from #define a (0x80) // definitions for LCD seegments on the Olimex LCD. 4-Mux operation is assumed #define b (0x40) // For more details on 4-Mux operation, gather your LCD datasheet, #define c (0x20) // TI's MSP430F449 User Guide (look for LCD Controller, then 4-Mux), #define d (0x01) // and MSP-449STK-2 schematic. You will need ALL these 3 when defining #define e (0x02) // each number or character. Remember, the Olimex LCD doesn't use a LCD driver! #define f (0x08) // You tell the LCD what characters to display. It's very time consuming!! #define g (0x04)
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Sheet1 Page 2 #define h (0x10) /********************* MAIN FUNCTION *********************/ unsigned char pressedKey=0 void main(void) { unsigned char myNum=0 WDTCTL = WDTPW + WDTHOLD init_sys() /* Loop forever waiting for input (where would you go if you exited?) */ while(1) { getKeys() if (hitKey =='0') { LEDOff() clearLCD() writeWord("SIMON") swDelay(5) clearLCD() } if(hitKey=='#') { unsigned char level=0 unsigned char cnt=0 unsigned char myArray[30] while (level<30) { myNum=rand()%4 myArray[level]= myNum+1 level++ } while (cnt<30) { for (int i=0 { if (myArray[i]==1) LEDdisplayHex(1)
Background image of page 2
Page 3 swDelay(1) LEDOff() if (myArray[i]==2) LEDdisplayHex(2) swDelay(1) LEDOff() if (myArray[i]==3) LEDdisplayHex(4) swDelay(1) LEDOff() if (myArray[i]==4) LEDdisplayHex(8) swDelay(1) LEDOff() } for (int n=0 { waitGetKeys() if ((pressedKey-0x30)==myArray[n]) { clearLCD() writeWord("YES") swDelay(1) clearLCD() } else { LEDOff() buzzerOn() swDelay(2) buzzerOff() clearLCD() writeWord("WRONG")
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 04/16/2008 for the course ECE 2801 taught by Professor Jarvis during the Spring '08 term at WPI.

Page1 / 24

SIMON WORKING CODE - #include &quot;msp430x44x.h&quot;...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online