From d090df94c5b22927c355cceeebe8b91a72a97712 Mon Sep 17 00:00:00 2001 From: Nick O'Leary Date: Tue, 14 Apr 2015 23:14:13 +0100 Subject: [PATCH] Arduino output - ensure string/number payloads handled A change to tighten the type checking meant passing a string '0' or '1' no longer matched the tests for numeric 0 or 1. --- nodes/core/hardware/35-arduino.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nodes/core/hardware/35-arduino.js b/nodes/core/hardware/35-arduino.js index 5f9d36701..8b4ba19bc 100644 --- a/nodes/core/hardware/35-arduino.js +++ b/nodes/core/hardware/35-arduino.js @@ -121,10 +121,10 @@ module.exports = function(RED) { node.board.pinMode(node.pin, node.state); node.on("input", function(msg) { if (node.state === "OUTPUT") { - if ((msg.payload === true)||(msg.payload == 1)||(msg.payload.toString().toLowerCase() == "on")) { + if ((msg.payload === true)||(msg.payload.toString() == 1)||(msg.payload.toString().toLowerCase() == "on")) { node.board.digitalWrite(node.pin, true); } - if ((msg.payload === false)||(msg.payload === 0)||(msg.payload.toString().toLowerCase() == "off")) { + if ((msg.payload === false)||(msg.payload.toString() == 0)||(msg.payload.toString().toLowerCase() == "off")) { node.board.digitalWrite(node.pin, false); } }