Exemplo n.º 1
0
int main(void)
{
	initRobotBase(); // Always call this first! 
	                  // The Processor will not work correctly otherwise.
					 
	// Write a text message to the UART:
	writeString_P("\nCounting and Receiving\n");
	
	// Define a counting variable:
	uint16_t counter = 0;
	
	// clear the UART buffer once at the start of the program
	clearReceptionBuffer();
	
	while(true)
	{
		// example of sending some data over UART
		counter++;    
		SendDataOverUART(counter);

		//example of receiving some data over UART
		ShowDataReceivedOverUART();
		
		mSleep(100); // delay 100ms = 0.1s
	}
	return 0;
}
Exemplo n.º 2
0
void askAQuestion(void)
{
	uint8_t bytesToReceive = 1;
	
	clearReceptionBuffer();
	switch(question)
	{
		case 0:
			writeString_P("What's your name? (Enter 8 characters please)\n"); 
			bytesToReceive = 8; 
		break;
		case 1:
			writeString_P("How old are you? (Enter 2 characters please)\n"); 
			bytesToReceive = 2;
		break;
		case 2: 
			writeString_P("Do you want to see some Text output? (\"y\" or \"n\")\n"); 
		break;
		case 3: 
			writeString_P("Do you want to see blinking LEDs and hear the beeper sound? (\"y\" or \"n\")\n"); 
		break;
		case 4: 
			writeString_P("Do you want to do all this again? (\"y\" or \"n\")\n"); 
		break;
	}

	for(size_t i=0; i<100 && getBufferLength() < bytesToReceive; ++i)
		;	
	char receiveBuffer[bytesToReceive];
	readChars(receiveBuffer, bytesToReceive);	

	switch(question)
	{
		case 0: 
			writeString_P("Hello \"");
			writeStringLength(&receiveBuffer[0],bytesToReceive,0);
			writeString_P("\" !\n");
		break;
		case 1: 
			writeString_P("So your age is: \""); 
			writeStringLength(&receiveBuffer[0],bytesToReceive,0);
			writeString_P("\" ! Guess what? Nobody cares... ;-)\n");
		break;
		case 2:
			if(receiveBuffer[0] == 'y') 
			{
				writeString_P("Here we go!\n");
				outputTextStuff();
				writeString_P("\n\nThat's it!\n\n"); 
			}
			else
				writeString_P("OK then... let's move on!\n"); 
		break;
		case 3:
			if(receiveBuffer[0] == 'y')
			{
				writeString_P("Now you get a led and beeper show!\n");
				uint8_t i = 0;
				for(;i < 10; i++)
					Leds_Beeper();
				writeString_P("Oh ... it's over!\n");
			}
			else
				writeString_P("Well, if you don't want that... :*( \n"); 
		break;
		case 4:
			if(receiveBuffer[0] == 'y')
			{
				writeString_P("Great! Here we go again...\n"); 
				question = -1;
			}
			else
			{
				writeString_P("OK good bye! I will wait \n");
				writeString_P("until someone resets me!\n"); 
				question = -2;
			}
		break;
	}
	
	question++;
}
Exemplo n.º 3
0
int main(void)
{
	initRP6Control(); // Always call this first! 
	                  // The Processor will not work correctly otherwise.
					 
	initLCD(); // Initialize the LC-Display (LCD)
			   // Always call this before using the LCD!

	// Play two sounds with the Piezo Beeper on the RP6Control:
	sound(180,80,25);
	sound(220,80,0);
	
	//IMPORTANT:
	I2CTWI_initMaster(100); // Initialize the TWI Module for Master operation
	// with 100kHz SCL Frequency
	
	// Register the event handlers:
	I2CTWI_setTransmissionErrorHandler(I2C_transmissionError);

	// Write a text message to the UART:
	writeString_P("{cmd=0x");
	writeInteger(CMD_LIFETIME, HEX);
	writeString_P("}\n");
	
	run_testCases();
	
	// Define a counting variable:
	//uint16_t counter = 0;
	
	// clear the UART buffer once at the start of the program
	clearReceptionBuffer();
	
	
	mSleep(1000);
	
	setStopwatch1(500);
	startStopwatch1();
	
	while(true)
	{
		//example of receiving some data over UART
		DoDataProcess();
		
		if(move_turning!=0)
		{
			if(move_turning == 1)
			{
				rotate(60, LEFT, 3, false);
			}
			else
			{
				rotate(60, RIGHT, 3, false);
			}
		}
		else		
		if(move_horizontal != 0)
		{
			if(move_horizontal > 0)
			{
				move(move_horizontal, FWD, 3, false);
			}
			else
			{
				move(move_horizontal, BWD, 3, false);
			}
		}
		
		//mSleep(100); // delay 100ms = 0.1s
	}
	return 0;
}