CART
  • Cart is empty.

    ItemQuantityPrice

    Total: $0

Multiply floats


Multiply 2 floats and print result to terminal and LCD

Toolkit:AVR Development System

Location:/bipom/devtools/WinAVR/minimaxavrc/Examples/float

Code Example


int main (void)
{
	float num1 = 12.5;
	float num2 = 1.5;
	float result = num1 * num2; 
	
	/* Initialize the system */
	uart1Init(19200);
	
	// Initialize the LCD 

	lcdInit();	
	pwmInit();	// Adjust LCD contrast 

	lcdControlCursor(CURSOR_OFF);

	// Write a results to the LCD 

	lcdClearDisplay();
	lcdSetTopLine();
	lcdPrintf("Float Example");
	lcdSetBottomLine();
	lcdPrintf("%.1f * %.1f = %.3f", num1, num2, result);

	// Write a results to the terminal

	uart1Printf("\n\rFloat Example");
	uart1Printf("\n\r%.1f * %.1f = %.3f", num1, num2, result);
	
   	for (;;);
}