Last active
March 18, 2021 14:48
-
-
Save ElectricImpSampleCode/146fc1199ba51d029872 to your computer and use it in GitHub Desktop.
Electric Imp imp API uart.configure() example 2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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