'Demonstrates the Serdetect, Serin, and Serout commands 'To start the progam hit a CR 'Builds a menu then lets you select options from the menu 'This program makes use of the serial port to display program status. Use one of ' the IDE terminal programs to display this information. bval var word 'Used to hold the auto detect baud rate. name var byte(30) cmd var byte clear dodetect: serdetect S_IN,IMODE,bval 'Lets wait for sync byte serout S_OUT,bval, ["We have your baud rate. ",10,13] '----------------------------------------------------------------------- 'Display the menu '----------------------------------------------------------------------- domenu: 'Menu system start here. serout S_OUT,bval,[10,13] serout S_OUT,bval,["1: Put ATOM to Sleep",10,13] serout S_OUT,bval,["2: Detect Baud Rate",10,13] serout S_OUT,bval,["3: Enter Name",10,13] serout S_OUT,bval,["4: Display Name",10,13] serout S_OUT,bval,["5: Shut the ATOM down",10,13] Serout S_OUT,bval,[10,13] serout S_OUT,bval,["Option "] 'Get the menu item here serin S_IN,bval,[dec1 cmd] branch cmd,[bad,dosleep,dodetect,getname,dispname,doend] 'Falls through or jumps here on 0 bad: serout S_OUT,bval,[10,13,"Invalid Command",10,13] goto domenu dosleep: serout S_OUT,bval,[10,13,"Night Night..",10,13] sleep 10 'Put the ATOM to sleep for 10 seconds. goto domenu doend: serout S_OUT,bval,[10,13,"Night Night..",10,13] end 'Shut the ATOM down (sleep forever) '--------------------------------------------------------------------- 'Get the users name '--------------------------------------------------------------------- getname: 'Ask for name serout S_OUT,bval,["What is your name? "] 'Read in users name here. Maximum of 30 characters or CR serin S_IN,bval,[str name\30\13] 'Display name until 30 characteres or end of data serout S_OUT,bval,["Hello ",str name \30\0] Serout S_OUT,bval,[10,13] goto domenu '----------------------------------------------------------------- 'Display the users name '----------------------------------------------------------------- dispname: 'Display name serout S_OUT,bval,["Hello ",str name \30\0] Serout S_OUT,bval,[10,13] goto domenu