Ejemplo n.º 1
8
void setup()
{

	initBoard();
	while(true)
	{
		if((AnalogRead(MIDDLE)<50))
		{
			initdisplay();display.println("MIDDLE");display.display();
			forward(100);
			delay(1000);
			stop();
			delay(1000);
		}
		else
		{
		}
		if((AnalogRead(LEFT)<50))
		{
			initdisplay();display.println("LEFT");display.display();
			left(50);
			delay(1000);
			stop();
			delay(1000);
		}
		else
		{
		}
		if((AnalogRead(RIGHT)<50))
		{
			initdisplay();display.println("RIGHT");display.display();
			right(50);
			delay(1000);
			stop();
			delay(1000);
		}
		else
		{
		}
	}
}
Ejemplo n.º 2
0
void setup()
{
	initBoard();
	float code = 0;
	while(true)
	{
		code = irReceiver.getIRRemoteCode();
		toneWithDelay(BuzzerPin, (code*440), 250);
		serial0.println(code);
	}
}
Ejemplo n.º 3
0
void setup()
{
	initBoard();

	servo0.attachAndWrite(0);
	for(unsigned int _i=0; _i<(unsigned int)(90); _i++)
	{
		servo0.attachAndWrite((servo0.read()+2));
		delay(200);
	}
}
Ejemplo n.º 4
0
void setup()
{
	initBoard();
	robot.motor0(-(100));
	while((robot.motor0()<100))
	{
		robot.motor0((robot.motor0()+1));
		serial0.println(robot.motor0());
		delay(100);
	}
	robot.motor0(0);
}
Ejemplo n.º 5
0
static void ResetTicTacToeCB(Widget, XtPointer, XtPointer)
{
    static int tics = 0;

    initBoard();

    if (tics++ % 2 == 0)
	autoMove();

    repaint();

    set_status("Welcome to Tic Tac Toe!");
}
Ejemplo n.º 6
0
int main (void)
{
    // Inicializamos la placa
    initBoard();
    
    // Bucle infinito
    while(1)
    {
        barraLed(getADCValue());
    }
    
    return 0;
}
Ejemplo n.º 7
0
int initGame()
{
	moveFlag=0;
	initBoard();
	if(TRUE == has_colors())
	{
		printBoard= printBoardWithColor;	
		initBoardColor();
	}
	else printBoard = printBoardBlackWhite;
	updateView();
	return 0;
}
Ejemplo n.º 8
0
void setup()
{
	initBoard();
	float vel = 50;
	float code = 0;
	while(true)
	{
		code = irReceiver.getIRRemoteCode();
		if(((int)(code)==(int)(2)))
		{
			motor0.setPower(vel);
			motor1.setPower(vel);
		}
		else
		{
		}
		if(((int)(code)==(int)(8)))
		{
			motor0.setPower(-(vel));
			motor1.setPower(-(vel));
		}
		else
		{
		}
		if(((int)(code)==(int)(6)))
		{
			motor0.setPower(-(vel));
			motor1.setPower(vel);
		}
		else
		{
		}
		if(((int)(code)==(int)(4)))
		{
			motor0.setPower(vel);
			motor1.setPower(-(vel));
		}
		else
		{
		}
		if(((int)(code)==(int)(5)))
		{
			motor0.setPower(0);
			motor1.setPower(0);
		}
		else
		{
		}
		delay(200);
	}
}
Ejemplo n.º 9
0
void main(void) {
  unsigned char counter;
  BYTE camera_on = FALSE;
  BYTE camera_rec = FALSE;
  BYTE sw_e_prev = FALSE;
  BYTE sw_w_prev = FALSE;
  TRISA = OUTPUT;
  initBoard();
  initLCD();
  clearLCD();
  backlightOn();
  setCursorLCD(0,0);
  appendStringToLCD("The Stalker");
  setCursorLCD(1, 0);
  appendStringToLCD("...........");
  while (TRUE) {
      if (SW_E == PRESSED) {
          sw_e_prev = TRUE;
      } else if (sw_e_prev == TRUE) {   //SW_E key up
            sw_e_prev = FALSE;
            clearLCD();
            setCursorLCD(0,0);
            if (camera_on == TRUE) {
                appendStringToLCD("Shut down cam");
                camera_on = FALSE;
            } else {
                appendStringToLCD("Power up cam");
                camera_on = TRUE;
            }
            switchPower();
      }

      if (SW_W == PRESSED) {
          sw_w_prev = TRUE;
      } else if (sw_w_prev == TRUE) {   //SW_E key up
            sw_w_prev = FALSE;
            clearLCD();
            setCursorLCD(0,0);
            if (camera_rec == TRUE) {
                appendStringToLCD("Stop rec");
                camera_rec = FALSE;
            } else {
                appendStringToLCD("Start rec");
                camera_rec = TRUE;
            }
            switchRec();
      }

      delay_ms(200);
  }
}
Ejemplo n.º 10
0
Archivo: mancala.c Proyecto: wfei/hw
int main(){
    printFlag = 1;
    printf("Author: Muxuan Wang\n");
    printf("Program 5: Mancala\n");
    printf("TA: Sean Deitz, W 9:00 AM\n");
    printf("Nov.28,2012\n");
    printf("\n");
    
    printf("Welcome to the game of Mancala, where you are playing against\n");
    printf("a computer opponent. Your holes are on the bottom row and\n");
    printf("you get to go first.\n");
    printf("\n");
    printf("\n");
    

    Hole board[14];
    initBoard(board);
    

    int player = 0;
    char userInput;
    int notDone = 1;
    int gameNum = 1;

    //each loop is a turn, and involves user and computer to play.
    while(notDone){
	printf("----------------------------------------------------------\n");
	playerToMove(player,board,gameNum);
	notDone = checkEndGame(board);
	if (notDone == 0) {
	    break;
	}
	player = (++player) % 2;
	playerToMove(player,board,gameNum);	    
	notDone = checkEndGame(board);
	gameNum++;
	player = (++player) % 2;
    }

    endGameScore(board);
    printf("The final board is: \n");
    displayBoard(board);
    if(board[13].capacity > board[6].capacity){
	printf("Computer Won!!\n");
    }else if(board[13].capacity < board[6].capacity){
	printf("You Won!!\n");
    }else{
	printf("Play Even!!");
    }

} // end of main
Ejemplo n.º 11
0
void setup()
{
	initBoard();

	float s0 = 0;
	while(true)
	{
		s0 = AnalogRead(sensor0);
		DigitalWrite(D13_LED, true);
		delay((s0*5));
		DigitalWrite(D13_LED, false);
		delay((s0*5));
	}
}
Ejemplo n.º 12
0
void setup()
{
	initBoard();
	while(true)
	{
		serial0.println("X, Y, Z accel values:");
		serial0.println(accel.readX());
		serial0.println(accel.readY());
		serial0.println(accel.readZ());
		//Blank line here:
		serial0.println("");
		delay(600);
	}
}
Ejemplo n.º 13
0
int main (void)
{
    // inicializamos la placa
    initBoard();
    
    // Bucle infinito
    while(1)
    {
        togglePin(&LED[0]);  // parpadear el led para saber que esta vivo
        delay_ms(500); // demora para que podamos apreciar el parpadeo
    }
    
    return 0; 
}
Ejemplo n.º 14
0
void setup()
{
	initBoard();

	float x = 0;
	float y = 0;
	while(true)
	{
		y = abs((sin(x)*100));
		AnalogWrite(PWM9, y);
		x = (x+0.01);
		delay(10);
	}
}
 Game():
 window(sf::VideoMode(500, 400), "Okno aplikacji"),
 messages_text("Komunikaty:"),
 player(nullptr),
 turn(0),
 left_button(false)
 {
     window.setFramerateLimit(100);
     loadFont();
     initBoard();
     initLines();
     initAreas();
     initMessages();
     initButton();
 }
Ejemplo n.º 16
0
void setup()
{
	initBoard();
	motor0.setPower(-(100));
	motor1.setPower(motor0.getPower());
	while((motor0.getPower()<100))
	{
		motor0.setPower((motor0.getPower()+1));
		motor1.setPower(motor0.getPower());
		serial0.println(motor0.getPower());
		delay(100);
	}
	motor0.setPower(0);
	motor1.setPower(0);
}
Ejemplo n.º 17
0
void setup()
{
	initBoard();
	while(true)
	{
		if((lightSens(LEFT)>lightSens(RIGHT)))
		{
			move(TURN_RIGHT);
		}
		else
		{
			move(TURN_LEFT);
		}
	}
}
Ejemplo n.º 18
0
int main() {
	initBoard();
	initLCD();
	backlightOn();
	clearLCD();
	Timer3_Init();
	while(1)
	{
		LCDSnelheid();
		_delay_ms(500);
	}
		//MakeCircle(A, Dflt, Dflt, Dflt, Dflt, Dflt, Dflt, Dflt, Dflt, Dflt,
			//	Dflt, Dflt, Dflt, Dflt, Dflt, Dflt);

}
void main (void)
{
    initBoard();
    initUSB();
    //sleepMillis(500);
    appMainInit();
    while (1)
    {  
#ifndef BUSYBLINK
        do_blink();
#endif
        usbProcessEvents();
        appMainLoop();
    }

}
Ejemplo n.º 20
0
void setup()
{
	initBoard();
	while(true)
	{
		if(DigitalRead(D14))
		{
			DigitalWrite(D14, true);
			toneWithDelay(BuzzerPin, NOTE_E4, 100);
		}
		else
		{
			DigitalWrite(D14, false);
		}
	}
}
Ejemplo n.º 21
0
//void  solveNQueens(int n);
void solveNQueens(int n)
{
	 int* board=     (int*) malloc(64*4);
	initBoard(board,8);
//	int k=generateRandomNum();
        printBoard(board,8);
	if(solveNQueensUtil(board,0)==1)
	{
		printf("Solution Exists\n");
//		printBoard(board,8);
	}
	else
		printf("Solution doesn't exist\n");
	 printBoard(board,8);
	
}
Ejemplo n.º 22
0
int main(int argc, char *argv[])
{
    char *inFile,*outFile;
    board b;
    int ret = 0;
    if(argc >= 3) {
        inFile = argv[1];
        outFile = argv[2];
        initBoard(inFile, &b);
        ret = answerWithMe(&b);
        //saveResult(outFile);
    }
    else {
        printf("useage solve [infile] [outFile]\n");
    }
    return ret;
}
Ejemplo n.º 23
0
Board::Board(const std::string &path) {
    initBoard();
    std::ifstream file(path.c_str());
    if (file.is_open()) {
        std::string line;
        for (int i = HEIGHT - 1; i >= 0; i--) {
            if (file.good()) {
                getline(file, line);
                addLine(line, i);
            } else {
                file.close();
                return;
            }
        }
        initRowCount();
    }
}
Ejemplo n.º 24
0
int main()
{
	int x,y,i,j;
	printf("盤面の大きさがxからyについて探します。(x<=y)\nxとyを入力してください。\nx,y = ");
	scanf("%d,%d",&x,&y);
	
	for(i=x;i<=y;i++){
		size=i;
		count=1;
		openBoard();
		initBoard();

		board[2][2]=1;
		knighttour(2,2);
		free(board);
	}
	return 0;
}
Ejemplo n.º 25
0
int main(void) {
    srand(GetTickCount());
    printf("Welcome to CubeGuess!\n----\n");
    //TODO other board sizes

    printf("Want to play?  (y/n)\n");
    int inPlay = getch();
    while (inPlay == 49 || inPlay == 121) {
        initBoard();
        prep();
        printBorderWithNumbers();

        play();
        printf("\nYou won!\nPlay again? (y/n)\n");
        inPlay = getch();
    }
    return 0;
}
Ejemplo n.º 26
0
//*****************************************************************************
//*****************************************************************************
int 
main(void)
{
	char data[80];
	//uint32_t adctest;
	bool masterDevice = false;
	
	//CONFIGURE BOARD
  PLL_Init(); //given to us
	initBoard();
	
	sprintf(data, "About to detect master.. \n\r");
	uartTxPoll(UART0, data);
	
	masterDevice = detectMaster();

	sprintf(data, "Detected master.. \n\r");
	uartTxPoll(UART0, data);
	
	if (masterDevice)
	{
			masterApp();
	}
	else
	{
			slaveApp();
	}
	
	//MAIN LOOP
  while(1)
  {
//		if (check)
//		{
//			adctest = GetADCval(1);
//			sprintf(data, "ADCVAL: %d \n\r", adctest);
//			uartTxPoll(UART0, data);
//			check = false;
//		}
//		examineButtons();
		
  };

  
}
Ejemplo n.º 27
0
int main (void)
{
    // Inicializamos la placa
    initBoard();
    
    // Inicializamos el LCD 
    configLCD(&databusLCD, &enPinLCD, &rwPinLCD, &rsPinLCD);
    
    // Escribimos texto en el LCD
    printLCD("Wake up Neo");
    
    // Bucle infinito
    while(1)
    {
        // Parpadeamos el led
        togglePin(&LED[0]);
        delay_ms(500);
    }
    
    return 0;
}
void main (void)
{
    initBoard();
    initUSB();
    blink(300,300);

    init_RF();
    appMainInit();

    usb_up();

    /* Enable interrupts */
    EA = 1;

    while (1)
    {  
        usbProcessEvents();
        appMainLoop();
    }

}
Ejemplo n.º 29
0
/**
 * Set up game with default values
 */
void setUpGame (ticTacToeBoard* selector, char *charPtr, unsigned short int* intPtr)
{
    // Sets turn number to 0
    *intPtr = 1;

    // Stores number of players as "num_players"
    intPtr[1] = numberOfPlayers();

    // Stores selected player as "user"
    charPtr[41] = playerSelect();

    // If there is an AI, ask for difficulty
    if(intPtr[1] == 1)
        intPtr[2] = findDifficulty(selector);

    // Flip coin to see who goes first
    coinFlip(charPtr);

    // Create a fresh board
    initBoard(charPtr);
}
Ejemplo n.º 30
0
int main(int argc, char ** argv)
{
	FILE * f = NULL;
	
	if (parseInput(argc, argv, &f)) { //parse our input; exit if there's an error
		printUsage(argv[0]);
		return -1;
	}
	
	sudoku s = initBoard(f); //initialize the board; exit if there's an error
	if (!s) {
		printUsage(argv[0]);
		return -1;
	}
	
	fclose(f);
	
  printSudoku(s, true);


}