/* Program ID : NXT_Rcv_Arduino.nxc Create date : 5-21-2011 Author : CH, Chen (Taiwan) Description : Receive message from Arduino via Hi-Speed communication(RS485) */ /* ******************************************************* * Waiting for message * ******************************************************* */ void Go_Rtn() { string strReceive; short xline = LCD_LINE4; while(TRUE) { until(RS485DataAvailable()) Wait(1000); RS485Read(strReceive); TextOut( 0, xline, strReceive); TextOut( 0, xline-8, " " ); if (xline > LCD_LINE7) xline = xline - 8; else xline = LCD_LINE4; } } /* ******************************************************* * Initialization * ******************************************************* */ void Init_Rtn() { // Configure Hi-Speed port(port 4) UseRS485(); RS485Uart(HS_BAUD_9600, HS_MODE_8N1); } /* ******************************************************* * Main routine * ******************************************************* */ task main() { ClearScreen(); TextOut(0, LCD_LINE1, "Arduino ---> NXT" ); TextOut(0, LCD_LINE2, " via RS485 " ); Init_Rtn(); Go_Rtn(); }