Skip to content

Instantly share code, notes, and snippets.

@ElectricImpSampleCode
Last active March 18, 2021 14:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ElectricImpSampleCode/146fc1199ba51d029872 to your computer and use it in GitHub Desktop.
Save ElectricImpSampleCode/146fc1199ba51d029872 to your computer and use it in GitHub Desktop.
Electric Imp imp API uart.configure() example 2
local serial = null;
// Set 'serial' according to imp type
switch (imp.info().type) {
case "imp001":
case "imp002":
serial = hardware.uart57;
break;
case "imp003":
serial = hardware.uartFG;
break;
case "imp004m":
serial = hardware.uartHJ;
break;
case "imp005":
serial = hardware.uart0;
break;
default:
// Unknown imp
throw("Unknown imp type detected");
}
// Configure 'serial'
serial.configure(19200, 8, PARITY_EVEN, 1);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment