コード例 #1
0
ファイル: main.c プロジェクト: csbaltar/Lab4
int main(void) {
   WDTCTL = WDTPW | WDTHOLD;	// Stop watchdog timer
	
   //initialize LCD
    initSPI();
    LCDinit();
    LCDclear();

   //Write to LCD


    while(1)
    {
    	write(Message1, 8);
    	Line2();
    	write(Message2,8);
    	_delay_cycles(100000);

    	scroll(Message1, MessageSize1);
    	scroll(Message2, MessageSize2);

    	LCDclear();
    }

	return 0;
}
コード例 #2
0
ファイル: main.c プロジェクト: ITCTYear3/Detect-O-Bot1000
void main(void) {
    char buffer[SCI_BUFSIZ+1] = {0};
    
    // Initialize all nessesary modules
    timer_init();
    SCIinit();
    encoder_init();
    motor_init();
    msleep(16); LCDinit();
    //start_heartbeat();    // Not used, TCNT overflow interrupts causing issues
    
    DDRP |= PTP_PTP0_MASK;  // Set DDR for laser GPIO
    
    // Motors off initially
    motor_set_speed(MOTOR1C, 0);
    motor_set_speed(MOTOR2C, 0);
    
    EnableInterrupts;
    
    LCDclear(); LCDputs("Ready.");
    SCIputs("HCS12 ready to go!");
    
    
    for(EVER) {
        SCIdequeue(buffer);
        cmdparser(buffer);
        memset(buffer, 0, SCI_BUFSIZ+1);    // Clear out the command buffer after each command parsed
        //LCDclear(); LCDprintf("\r%7d  %7d\n%7d  %7d", drive_value1, drive_value2, speed_error1, speed_error2);
    }
}
コード例 #3
0
ファイル: RoboticArm.c プロジェクト: chinex-eze/RoboticArm
void init() 
{
	TCCR1A |= (1 << WGM11); 
	TCCR1B |= (1 << WGM12) | (1 << WGM13); 

	TCCR3A |= (1 << WGM31); 
	TCCR3B |= (1 <<WGM32) | (1 <<WGM33); 

	TCCR1A |= (1 << COM1A1) | (1 <<COM1A0) | (1 <<COM1B1) | (1 <<COM1B0) | (1 << COM1C1) | (1 <<COM1C0);  
	TCCR3A |= (1 << COM3A1) | (1 << COM3A0) | (1 << COM3B1) | (1 << COM3B0); 

	TCCR1B |= (1 << CS11); 
	TCCR3B |= (1 << CS31); 
	
	ICR3 = 40000; 
	ICR1 = 40000; 

	//set PWM pins as output 
	DDRB |= (1 << 5) | (1 << 6) | (1 << 7);  
	DDRE |= (1 << 3) | (1 << 4); 

	LCDinit(); 
	LCDclr();  
	LCDcursorOFF(); 
	LCDstring("GRIP MODE", 9); 
} 
コード例 #4
0
ファイル: ReactionTimer.c プロジェクト: HarrisonW/ECE4760
//Initialize the LCD
void InitLCD(void){
  LCDinit();  //initialize the display
  LCDcursorOFF();
  LCDclr();        //clear the display
  LCDGotoXY(0,0);
  CopyStringtoLCD(LCDHello, 0, 0);
  CopyStringtoLCD(LCDHello2, 0, 1);
}
コード例 #5
0
ファイル: main.c プロジェクト: GoodRyan/Lab5Interrupts
int main(void) {
    WDTCTL = WDTPW | WDTHOLD;	// Stop watchdog timer

    initSPI();

    LCDinit();

    LCDclear();

    unsigned char player = initPlayer();

    init_timer();
    init_buttons();
    __enable_interrupt();
   	printPlayer(player);
    while(1)
    {

    	player = movementCheck(player);
    	if(LOSE == 1){
    		LCDclear();
    		print("GAME");
    		secondLine();
    		print("OVER");
    		firstLine();
    		GAMEOVER = 1;
    		waitForP1ButtonRelease(BIT1|BIT2|BIT3|BIT4);
    		debounce();
    	}
    	if(didPlayerWin(player)){
    		LCDclear();
    		print("YOU");
    		secondLine();
    		print("WON");
    		firstLine();
    		GAMEOVER = 1;
    		waitForP1ButtonRelease(BIT1|BIT2|BIT3|BIT4);
    		debounce();
    	}
    	if(GAMEOVER){
    		char buttonsToPoll[4] = {BIT1, BIT2, BIT3, BIT4};
    		while(!pollP1Buttons(buttonsToPoll, 4)){
    			//poll until something is pressed
    		}
    		TAR = 0;
    		LOSE = 0;
    		TIMER = 0;
    		GAMEOVER = 0;
    		LCDclear();
    		player = initPlayer();
    		printPlayer(player);
    	}
    }

    return 0;
}
コード例 #6
0
ファイル: main.c プロジェクト: lilmaine/Lab4
/*
 * main.c
 */
int main(void) {
        WDTCTL = WDTPW | WDTHOLD;        // Stop watchdog timer

        initSPI(); // same as asm lab
        LCDinit();
        LCDCLR();
        doWork(); // put the bulk of the main work in lcd.c to keep main.c concise

        return 0;
}
コード例 #7
0
ファイル: SousVide.c プロジェクト: HarrisonW/ECE4760
//Initialize the LCD
void initLCD(){
	LCDinit();	//initialize the display
	LCDcursorOFF();
	LCDclr();				//clear the display
	LCDGotoXY(0,0);
	const uint8_t LCDHelloTop[] PROGMEM = "Water Cooler v9000\0";
	const uint8_t LCDHelloBot[] PROGMEM = "\0";
	CopyStringtoLCD(LCDHelloTop, 0, 0);
	CopyStringtoLCD(LCDHelloBot, 0, 1);
}
コード例 #8
0
ファイル: main.c プロジェクト: ryanlamo/lab5
int main(void) {
    WDTCTL = WDTPW | WDTHOLD;

    player = initPlayer();

    initSPI();
    LCDinit();
    LCDclear();

    RenewGame();

    printPlayer(player);


    init_timer();
    init_buttons();
   __enable_interrupt();


    while(1)
    {

    	if (player==0xC7)
    	{

    		TACTL &= ~TAIE;
    		LCDclear();
    		cursorToLineOne();
    		writeString("YOU");
    		cursorToLineTwo();
    		writeString("WON!");
    		gamedone = 1;
    		_delay_cycles(1000000);

   	    }


    	if (CountTimer >=4)
    	{
    		TACTL &= ~TAIE;
    		LCDclear();
    		cursorToLineOne();
    		writeString("Game");
    		cursorToLineTwo();
    		writeString("Over");
    		gamedone = 1;
    		_delay_cycles(1000000);

    	}

    }

	
	return 0;
}
コード例 #9
0
ファイル: lab_4.c プロジェクト: craigodaniel/lcd
int main(void){
	WDTCTL = WDTPW | WDTHOLD;
			char message[] = "ECE 382 is my favorite class! ";
			char message2[]= "I got 99 problems... but a git ain't one. ";
			initSPI();
			LCDinit();
			LCDclear();
			cursorToLineOne();
			scrollString(message,message2);
			while (1){};
}
コード例 #10
0
ファイル: main.c プロジェクト: travisschriner/Lab4
/*Author: Travis Schriner
 * Date 21 Oct 2013
 * Description: This program interacts with the
 * LCD in the geekbox and allows me to write to it
 *
 */
int main(void) {
    WDTCTL = WDTPW | WDTHOLD;	// Stop watchdog timer
	
    initSPI();
    LCDinit();
    LCDclear();

    char *topMessage = "ECE382 is my Favorite Class!";
    char *prompt = "Message?";
    char *promptKey = "Press123";
    char *message1 = "This is message 1 fool!";
    char *message2 = "This is message 2 fool!";
    char *message3 = "This is message 3 fool!";



    cursorToLineOne();
    writeString(prompt);
    cursorToLineTwo();
    writeString(promptKey);


    configureP1PinAsButton(BIT1|BIT2|BIT3);         // configure pins 1, 2, and 3 as buttons

       P1DIR |= BIT0|BIT6;                             // set launchpad LEDs to output

           char buttons[] = {BIT1, BIT2, BIT3};
           char pressedButton = pollP1Buttons(buttons, 3);

           switch (pressedButton) {
               case BIT1:

            	   waitForP1ButtonRelease(BIT1);
            	   scrollString(topMessage, message1);

                   break;
               case BIT2:

            	   waitForP1ButtonRelease(BIT2);
            	   scrollString(topMessage, message2);
                   break;
               case BIT3:

            	   waitForP1ButtonRelease(BIT3);
            	   scrollString(topMessage, message3);

                   break;
           }
 while(1){

 }
}
コード例 #11
0
ファイル: LCD_projekt.c プロジェクト: OscarJL/ims_project
//----------------------Funktioner------------------------
void init_LCD()
{
	const char lcd_text[] = "ADC value:";
	LCDinit();
	_delay_ms(1000);
	LCDclr();
	_delay_ms(1000);
	LCDhome();
	_delay_ms(1000);
	LCDstring((uint8_t*) lcd_text, (uint8_t) strlen(lcd_text));
	_delay_ms(1000);
	LCDvisible();
}
コード例 #12
0
ファイル: main.c プロジェクト: JennaeN/LabNotebook
/*
 * main.c
 */
int main(void) {
	WDTCTL = WDTPW | WDTHOLD;	// Stop watchdog timer


	//Create strings of text to output to the user
	char * requiredMsg = "ECE382 is my favorite class! ";
	char * prompt = "Message?";
	char * promptKey = "Press123";

	char * message1 = "Learn from yesterday... ";

	char * message2 = "Live for today... ";

	char * message3 = "Hope for tomorrow. ";


	//SPI initialization function
	initSPI();

	// LCD initialization function
	LCDinit();

	//Clear the LCD screen
	LCDclr();

	//Position the cursor to write the prompt to the user.
	cursorToLineOne();
	writeString(prompt);

	cursorToLineTwo();
	writeString(promptKey);

	int buttonPushed = 0;
	//A different value is returned depending on which button is pushed.
	buttonPushed = pollButton();

	//Move the selected message to the screen
	if (buttonPushed == 1) {
		scrollString(requiredMsg, message1);
	}

	if (buttonPushed == 2) {
		scrollString(requiredMsg, message2);
	}

	if (buttonPushed == 3) {
		scrollString(requiredMsg, message3);
	}

	return 0;
}
コード例 #13
0
ファイル: newfile.c プロジェクト: reebot/wins
int main(void) {
    // Disable Watch Dog Timer
    RCONbits.SWDTEN = 0;
    // for LED
    ODCAbits.ODA6 = 0;
    TRISAbits.TRISA6 = 0;
    TRISAbits.TRISA4 = 0;
    TRISAbits.TRISA0 = 0;


    //Enable channel
    OpenI2C1(I2C_ON, I2C_BRG);
    //Setup_MPU6050();
    //LDByteWriteI2C(MPU6050_ADDRESS, MPU6050_RA_PWR_MGMT_1, 0x00);
    SPI1Init();
    SPI2Init();
    LCDinit();
    LCDProcessEvents();

    //_05ms = false;
    //TimerInit();
    unsigned char fifocount[2];

    while (1) {
        if (updateScreen) {
            LCDProcessEvents();
            updateScreen = false;
        }
        if (getFifo) {
            LDByteReadI2C(MPU6050_ADDRESS, MPU6050_RA_FIFO_COUNTH, &fifocount[0], 2);
            if (((((unsigned int) fifocount[0]) << 8) | fifocount[1]) == 1024) {
                //need to reset
                unsigned char temp = 0;
                LDByteReadI2C(MPU6050_ADDRESS, MPU6050_RA_USER_CTRL, &temp, 1);
                LDByteWriteI2C(MPU6050_ADDRESS, MPU6050_RA_USER_CTRL, 0b00000100 | temp);
                /*
                int i = 0;
                for(i = data_p; i < data_p+CHUNK_SIZE; i++){
                    rpiData.imu[i] = 0;
                }*/
                __builtin_btg((unsigned int *) &LATA, 0);
            } else if (((((unsigned int) fifocount[0]) << 8) | fifocount[1]) >= 42) {
                LDByteReadI2C(MPU6050_ADDRESS, MPU6050_RA_FIFO_R_W, &rpiData.imu[data_p], DMP_PACKET_SIZE);
                __builtin_btg((unsigned int *) &LATA, 4);
            }
            getFifo = false;
        }
        __builtin_btg((unsigned int *) &LATA, 6);
    }
    return 0;
}
コード例 #14
0
ファイル: avr.c プロジェクト: olcai/sommar
void lcd_init(void)
{
  /* setup LCD on portB and display greeting */
  LCDinit(); 
  LCDclr();
  LCDGotoXY(0,0);
  LCDcursorOFF(); 

  LCDstring((uint8_t*)"System online", 13);
  LCDGotoXY(0,1);
  if(config.flags.mode == CONFIG_MODE_BASE)
    LCDstring((uint8_t*)"base", 4);
  else
    LCDstring((uint8_t*)"node", 4);
}
コード例 #15
0
ファイル: main.c プロジェクト: JahwnMallard/Lab4
int main(void) {
	WDTCTL = WDTPW | WDTHOLD;	// Stop watchdog timer
	char mainMESSAGE[] = { 'E', 'C', 'E', '3', '8', '2', ' ', 'i', 's', ' ',
			'm', 'y', ' ', 'f', 'a', 'v', 'o', 'r', 'i', 't', 'e', ' ', 'c',
			'l', 'a', 's', 's', '!'};
	int mainMessageLength = 29;
	char * mainMessagePointer = &mainMESSAGE[0];
	initSPI();
	LCDinit();
	LCDclear();
	while (1) {
		scrollString(mainMessagePointer, mainMessagePointer, mainMessageLength);
	}

	return 0;
}
コード例 #16
0
ファイル: init.c プロジェクト: dmitryshagin/dynamic_blender
void init()
{
    load_eeprom_data();
    init_outputs();
    LCDinit();//init LCD bit, dual line, cursor right
    LCDclr();//clears LCD
    init_adc();
    uart0_init(UART_BAUD_SELECT(115200UL, F_CPU));
    if(target.oxygen > 40000){
        target.oxygen = 40000;
    }
    while(ANY_BUTTON_PRESSED){;}
    _delay_ms(150);
    sei();
    set_current_working_mode(MODE_CALIBRATE);
    set_countdown_timer(15);

}
コード例 #17
0
ファイル: demo5.c プロジェクト: Eranda43/Lordfiles
int main(void){

///////////////////initialize stuff here////////////////////////

	DDRA |= _BV(DDA0);	// PortA pin 0 as output
	MCUCSR = (1<<JTD);
	MCUCSR = (1<<JTD);
	LCDinit(); //initialize LCD


////////////////////////////////////////////////////////////////////////////       initialize timer   ////////////////

	TCCR1B |= (1<<CS10 | 1<<CS12 | 1<<WGM12);
	TIMSK |= 1<<OCIE1A;
///////////////////////////////////////////////////////////////////////////         initialize comparator      ///////////////
	ACSR &= ~(1<<ACD);
	ACSR &= ~(1<<ACBG);

//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$44 Main code $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$


	timer150(); // enable the timer to check pulse every 150 ms

	Go_to_Loc(4,0);
	Stringme("Node ID");

while(1){  // while loop 1


	Go_to_Loc(4,1);
	Send_int_val(nodeID[0]);
	Go_to_Loc(7,1);
	Send_int_val(nodeID[1]);
	Go_to_Loc(10,1);
	Send_int_val(nodeID[2]);
	_delay_ms(20);


} //end of while loop 1

//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ End of main code $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$


}
コード例 #18
0
ファイル: main.c プロジェクト: kbradley91/Lab9
int main(void) {
	
	DisableDog();
	CPUinit();
	EALLOW;
	outputEnable();
	LCDinit();
	LCDclear();
	initADC();
	DAC_init();
//	SRAMwrite(0);
//	SRAMaddress = 0x260000; //shouldn't need SRAM here
	fft_init();
	initBuffers();

	timerINIT(ISRvalue, samplingRate);




	while(1){
		if(sampleBufferFull){
			fft.InBuf = &sampleBuffer[0];
			int i;
			for(i = 0;i<FFT_SIZE;i++){
				outBuffer[i] = 0;
			}
			for(i=0;i<FFT_SIZE/2;i++){
				MagBuffer[i] = 0;
			}
			RFFT_f32(&fft);
			//fft.MagBuf = &sampleBuffer[0];
			RFFT_f32_mag(&fft);

			sampleBufferFull = 0;
			EINT;
		}
		else{
			//do nothing
		}

	}
	return 0;
}
コード例 #19
0
ファイル: system.c プロジェクト: olcai/sommar
void panic(const char* msg)
{
    unsigned char panic_msg[] = "KERNEL PANIC!";
    cli();
    PORTC=0xFF;
    LCDinit(); 
    LCDclr();
    LCDGotoXY(0,0);
    LCDcursorOFF(); 
    LCDstring(panic_msg, sizeof(panic_msg)-1);
    LCDGotoXY(0,1);
    while(*msg)
	LCDsendChar(*(msg++));
    while(1)
    {
        PORTC = ~PORTC;
        _delay_ms(500);
    }
}
コード例 #20
0
ファイル: main.c プロジェクト: ITCTYear3/Elevator
void main(void) {
    
    //byte b;
    
    DDRS_DDRS2 = 1; DDRS_DDRS3 = 1; // Enable LEDs
    DDRJ_DDRJ6 = 0; DDRJ_DDRJ7 = 0; // Enable switches
    
    timer_init();
    CANinit(MSCAN_NODE_ID);
    
    // Clear all MSCAN receiver flags (by setting bits)
    CANRFLG = (CANRFLG_RXF_MASK | CANRFLG_OVRIF_MASK | CANRFLG_CSCIF_MASK | CANRFLG_WUPIF_MASK);
    
    sci_init();
    
#ifdef USE_LCD
    msleep(16); // wait 16ms before init LCD
    LCDinit();  // initialize LCD, cursor should be visible with blink after
#endif
    
#ifdef USE_LCD2
    lcd_init();
#endif
    
#ifdef USE_LED7
    led7_init();
    led7_write(LED7_HBARS);
#endif
    
    EnableInterrupts;
    
    sci_sendBytes((byte*)"Ready", 6);   // Send ready message indicator via serial
    
    for(;;) {
        /*
        while ( sci_bytesAvailable() ) {
            sci_readByte(&b);
            lcd_putc(b);  
        }*/
        RUN();
    }
}
コード例 #21
0
ファイル: ARobotic.cpp プロジェクト: Ares566/ARobotic
//инициализация робота
void ARobotic::initAR(int mode,uint16_t ar_width){
	_ar_width = ar_width;
	//инициализация дисплея
	if (mode && AR_M_WITH_LCD){
		LCDinit();
		clearDisplay();
	}
	
	//если режим работы с энкодерами
	if (mode && AR_M_WITH_ENC){
		//подключаем энкодеры
		pinMode(2, INPUT);   //2 пин отвечает за 0 прерывание
		digitalWrite(2, HIGH);       // включаем подтягивающий резистор
		attachInterrupt(0, encoderFuncM_L, CHANGE);  // энкодер левого колеса

		pinMode(3, INPUT);   //3 пин отвечает за 1 прерывание
		digitalWrite(3, HIGH);       // включаем подтягивающий резистор
		attachInterrupt(1, encoderFuncM_R, CHANGE);  // энкодер правого колеса
	}
}
コード例 #22
0
ファイル: main.c プロジェクト: ITCTYear3/Elevator
void main(void) {
    
    DDRS_DDRS2 = 1; DDRS_DDRS3 = 1; // Enable LEDs
    DDRJ_DDRJ6 = 0; DDRJ_DDRJ7 = 0; // Enable switches
    
    timer_init();
    CANinit(MSCAN_NODE_ID);
    
    // Clear all MSCAN receiver flags (by setting bits)
    CANRFLG = (CANRFLG_RXF_MASK | CANRFLG_OVRIF_MASK | CANRFLG_CSCIF_MASK | CANRFLG_WUPIF_MASK);
    
    msleep(16); // wait 16ms before init LCD
    LCDinit();  // initialize LCD, cursor should be visible with blink after
    
    EnableInterrupts;
    
    for(;;) {
        RUN();
    }
}
コード例 #23
0
ファイル: main.c プロジェクト: kbradley91/Lab7
int main(void) {
	
	DisableDog();
	CPUinit();
	EALLOW;
	outputEnable();
	LCDinit();
	LCDclear();
	initADC();
	DAC_init();
	init_buffer();
	timerINIT(ISRvalue, samplingRate);

	while(1){

	}


	return 0;
}
コード例 #24
0
ファイル: main.c プロジェクト: AndrewTymchenko/Lab5
int main(void)
{
        WDTCTL = (WDTPW|WDTHOLD);


        player = initPlayer(); //debugging: had player defined twice, caused * to jump around alot
        initSPI();
        LCDinit();
        LCDclear();
        printPlayer(player);
        init_timer();
        init_buttons();
        __enable_interrupt();


        while(1)
        {
        	 if(player == 0xC7){
        	                    TACTL &= ~TAIE;
        	                    LCDclear();
        	                    cursorToLineOne();
        	                    writeString("YOU");
        	                    cursorToLineTwo();
        	                    writeString("WON!");
        	                    gameover = 1;
        	                    _delay_cycles(100000);
        	            }
        	            if(timerCount >= 4){
        	                    TACTL &= ~TAIE;
        	                    LCDclear();
        	                    cursorToLineOne();
        	                    writeString("Game");
        	                    cursorToLineTwo();
        	                    writeString("Over!");
        	                    gameover = 1;
        	                    _delay_cycles(100000);
        	            }
        }

        return 0;
}
コード例 #25
0
ファイル: main.c プロジェクト: shebu18/5110-LCD
int main(void)
{
	GPIO_InitTypeDef GPIO_InitStructure;
	//RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOB, ENABLE); //enable gpioB peripherial clock
	RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA, ENABLE);	//enable gpioA peripherial clock

	GPIO_InitStructure.GPIO_Pin = SCE|RES|DC|SCLK|SDIN;
	GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
	GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
	GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
	GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
	GPIO_Init(GPIOA, &GPIO_InitStructure);

	GPIO_SetBits(GPIOA, SCE|RES|DC|SCLK|SDIN);

	LCDinit(); //initialize LCD parameters


    while(count--)
    {
    	LCDString("Hello worlds! ");
    }
    setXY(0,5);
    //while(count2--){

    	//writeCharInv('C');
   // }

    newString("0.123457",0,2);
	
		
    floatToString(value-count2);
		newFont('V',55,5);

		/*To Do:
			
		*/
		
    return 0;
	
}
コード例 #26
0
ファイル: main.c プロジェクト: pedrovanzella/arm-smartcard
int main(void)
{
	unsigned char buffer[17]; // Where we are reading to
	buffer[16] = '\0'; // Terminating string
	int page = 0xa0;
	int offset = 0;

	init_timer0(); // LCD needs timer0 to function
	LCDinit(); // Initializing LCD
	ini_i2c(); // Initializing i2c

	/******************** MAIN LOOP *********************/
	while(1) {
		offset &= 0xff;
		buffer[0] = offset;
		escreve_i2c(page, buffer, 1); /* tell i2c we want to read from page + offset */
		if(le_i2c(page, buffer, 16)) { /* If we failed to read 16 bytes */
			LCDclear();
			LCDgoto(0, 0);
			LCDputs("Problema de leitura");
			LCDgoto(1, 0);
			LCDputs(buffer);
		} else {
			LCDgoto(0, 0); // Go to first line, first column
			LCDputs("Pg = ");
			LCDputchar(page + '0'); // Prints page number as char

			LCDgoto(0, 8); // Go to the second half of first line
			LCDputs("Of = ");
			LCDputchar(offset + '0'); // Prints offset as char

			LCDgoto(1, 0); // Fisrt column of the second line
			LCDputs(buffer); // Prints buffer
		}
	}

	return 0;
}
コード例 #27
0
ファイル: main.c プロジェクト: dan5912/PCC-Robot-Hello-World
void main(void) {
    
    __delay_ms(100); // Wait for things to settle
    // Setting up Button Input
    ANSELB = 0; // Digital Input
    
    // LCD initilization
    LCDinit();
    
    
    TRISBbits.RB5 = 1; // RB5 is button input
    WPUBbits.WPUB5 = 1; // Weak pullup enabled for B5
    __delay_ms(100);   // Wait for things to settle
    while(!PORTBbits.RB5)  // Wait until B5 goes low
    {
        continue;
    }
    
    LCDputs("Ruth"); // Add Ruth to line 1
    char *message = "Hello World - April 2016";  // Store message for line 2 in a variable
    
    while(1)
    {
        for(int i = 0; i < 9; i++)  // For loop to add to the message pointer
        {
            LCDwriteLineTwo((message+i)); // Print message starting at incremented pointer up to \0 
            __delay_ms(1000); // Delay cannot be much longer than a second due to program limits
            __delay_ms(1000);
            __delay_ms(250);
        }
        __delay_ms(1000); // Wait 1 extra second before beginning again
    }
    
    
    return;
}
コード例 #28
0
ファイル: main.c プロジェクト: cmjdev/EECT222-Theremin
/* init configures LED's for vumeter and initializes LCD / ATD / PWM / RTI*/
void init(void) {
  
  DDRB = 0xFF;
  PORTB = 0x00;
  DDRJ = 0x02;
  PTJ = 0x00;
  DDRT = 0x20;
  
  DDRP = 0xFF;
  PTP = 0xFF;
  
  PWMPRCLK = 0x03;   // 4MHz / 8 = 500kHz
  PWMSCLA = 0x0A;    // 500kHz / (2*10) =25kHz
  PWMCLK = 0x20;     // PWM source channel 5
  PWMPOL = 0x20;     // High then low
  PWMCAE = 0x00;     // Left aligned
  PWMCTL = 0x0F;     // 8-bit, 15 cycle wait
  PWME = 0x20;       // Enable PWM5
  //PWMCNT5 = 0x00;    //Clear PWMCNT05
  
  ATDinit();
  LCDinit();
  RTIinit();
}
コード例 #29
0
ファイル: main.c プロジェクト: Jsrazz/Lab4
/*Author C2C Rasmussen
 * Date Oct 28 13
 *
 *  Implements the program
 * main.c
 */
int main(void) {
	WDTCTL = WDTPW | WDTHOLD;	// Stop watchdog timer

	//stores strings in an arrays (idea from C2C Mordan)

	char string1[] = {'E','C','E',' ','3', '8', '2',' ','i','s',' ','m','y',' ','f','a','v','o','r','i','t','e',' ','c','l','a','s','s','!',' ',' '};

	char message[] = {'P','R','E','S','S',' ','K','E','Y',' ',' '}; // 11 in length
	char message1[] = {'w','a','z','z','u','p'}; // 6 in length
	char message2[] = {'h','o','w',' ','d','o',' ','y','o','u', ' ','d','o','?',' ',' '}; // 16 in length
	char message3[] = {'f','a','l','c','o','n',' ','p','u','n','c','h',' ',' '}; // 14 in length

	initSPI();
	LCDinit();
	LCDclear();

		while(1){
	cursorToLineOne();
	createString(message, 11);

	scrollLCD(message, 11);



	configureP1PinAsButton(BIT1|BIT2|BIT3);         // configure pins 1, 2, and 3 as buttons

	P1DIR |= BIT0|BIT6;                             // set launchpad LEDs to output

	while (1) {
		char buttons[] = {BIT1, BIT2, BIT3};
		char pressedButton = pollP1Buttons(buttons, 3);

		switch (pressedButton) {
		case BIT1:							// detects if Bit1 is enabled
			P1OUT ^= BIT0|BIT6;
			waitForP1ButtonRelease(BIT1);

			while(1){
			cursorToLineOne();						//passes new message
			createString(string1, 31);
			cursorToLineTwo();
			createString(message1, 6 );
			scrollLCD(string1, 31);
			scrollLCD(message1, 6);
			}
			// do something in response
			break;


		case BIT2:

			P1OUT ^= BIT0|BIT6;
			waitForP1ButtonRelease(BIT2);
			// do something in response

			while(1){
			cursorToLineOne();
			createString(string1, 31);
			cursorToLineTwo();
			createString(message2, 16 );
			scrollLCD(string1, 31);
			scrollLCD(message2, 16);
			}
			break;


		case BIT3:
			// toggle LEDs and wait for release
			P1OUT ^= BIT0|BIT6;
			waitForP1ButtonRelease(BIT3);


			while(1){
			cursorToLineOne();
			createString(string1, 31);
			cursorToLineTwo();
			createString(message3, 14 );
			scrollLCD(string1, 31);
			scrollLCD(message3, 14);
			}
			break;
		}
	}

		}

}
コード例 #30
0
ファイル: main.c プロジェクト: JennaeN/Lab05_Game
int main(void) {
	WDTCTL = WDTPW | WDTHOLD;	// Stop watchdog timer

	//Use seed to create a random number
	static const char seed = 1234;

	//Define all of the strings that will be used in the program
	char * you = "YOU     ";
	char * win = "WIN!    ";
	char * game = "GAME    ";
	char * over = "OVER!   ";
	char * boom = "BOOM!   ";
	char * space = "        ";

	//Initialize the timer
	init_timer();

	//Initialize the buttons
	init_buttons();

	//Enable the interrupt
	__enable_interrupt();

	//SPI initialization function
	initSPI();

	// LCD initialization function
	LCDinit();

	//Clear the LCD screen
	LCDclr();

	//Place the player at the starting location
	printPlayer(location);

	//Create random mine placement
	char random = prand(seed);
	random = prand(random);
	char mine1Location = 0x81 + random % 7;
	random = prand(random);
	char mine2Location = 0xC0 + random % 7;

	//print the first mine, and check to make sure the second mine is printed in a place that the user can still win the game
	printMine(mine1Location);
	while (mine2Location == mine1Location
			|| mine2Location == (mine1Location + 0x40)
			|| mine2Location == (mine1Location + 0x41)
			|| mine2Location == (mine1Location + 0x3F)) {
		random = prand(random);
		mine2Location = 0xC0 + random % 7;
	}
	printMine(mine2Location);

	//during the rest of the game
	while (1) {

		//This is the end of the level - player wins!
		if (location == 0xC7) {
			print2LineMessage(you, win);
			//Set flag and increment to a value above 4 so that 'game over' is not printed
			flag = 5;
			increment = 5;

			//Reset the game for the next level
			while (flag > 4) {
			}
			LCDclr();
			location = initPlayer();
			printPlayer(location);
			mine1Location = 0x81 + random % 7;
			printMine(mine1Location);
			while (mine2Location == mine1Location
					|| mine2Location == (mine1Location + 0x40)
					|| mine2Location == (mine1Location + 0x41)
					|| mine2Location == (mine1Location + 0x3F)) {
				random = prand(random);
				mine2Location = 0xC0 + random % 7;
			}
			printMine(mine2Location);
			increment = 0;
		}

		//The game is over if the player hits a mine
		if (location == mine1Location || location == mine2Location) {
			flag = 4;
			print2LineMessage(boom, space);
			__delay_cycles(444444);
		}

		//If two seconds have passed, increment the mines to move in the opposite directions of each other
		if (increment == 4) {
			clearPlayer(mine1Location);
			clearPlayer(mine2Location);
			mine1Location--;
			mine2Location++;
			printMine(mine1Location);
			printMine(mine2Location);
			increment = 0;
		}

		//If the player loses, print 'game over'
		if (flag == 4) {
			print2LineMessage(game, over);
			flag = 5;
			increment = 5;

			//Reset the game for a new level
			while (flag > 4) {
			}
			LCDclr();
			location = initPlayer();
			printPlayer(location);
			flag = 0;
			increment = 0;
			mine1Location = 0x81 + random % 7;
			printMine(mine1Location);
			while (mine2Location == mine1Location
					|| mine2Location == (mine1Location + 0x40)
					|| mine2Location == (mine1Location + 0x41)
					|| mine2Location == (mine1Location + 0x3F)) {
				random = prand(random);
				mine2Location = 0xC0 + random % 7;
			}
			printMine(mine2Location);
		}
	}

}