mirror of
https://github.com/node-red/node-red-nodes.git
synced 2023-10-10 13:36:58 +02:00
Tidy Arduino - make it use integers.
plus slight tidy of docs
This commit is contained in:
parent
90878364ac
commit
d457b68941
@ -41,7 +41,7 @@
|
|||||||
<p>The Arduino must be loaded with the Standard Firmata sketch available in the Arduino examples.</p>
|
<p>The Arduino must be loaded with the Standard Firmata sketch available in the Arduino examples.</p>
|
||||||
<p>You can select either Digital or Analogue input. Outputs the value read as <b>msg.payload</b> and the pin number as <b>msg.topic</b>.</p>
|
<p>You can select either Digital or Analogue input. Outputs the value read as <b>msg.payload</b> and the pin number as <b>msg.topic</b>.</p>
|
||||||
<p>It only outputs on a change of value - fine for digital inputs, but you can get a lot of data from analogue pins which you must then handle.</p>
|
<p>It only outputs on a change of value - fine for digital inputs, but you can get a lot of data from analogue pins which you must then handle.</p>
|
||||||
<p>You can set the sample rate in ms from 20 to 65535.</p>
|
<p>You can set the sample rate from 20 to 65535 mS.</p>
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
@ -95,7 +95,7 @@
|
|||||||
<script type="text/x-red" data-help-name="arduino out">
|
<script type="text/x-red" data-help-name="arduino out">
|
||||||
<p>Arduino output node. Connects to local Arduino and writes to the selected digital pin. Uses <a href="http://firmata.org/" target="_new"><i>Firmata</i>.</a></p>
|
<p>Arduino output node. Connects to local Arduino and writes to the selected digital pin. Uses <a href="http://firmata.org/" target="_new"><i>Firmata</i>.</a></p>
|
||||||
<p>The Arduino must be loaded with the Standard Firmata sketch available in the Arduino examples.</p>
|
<p>The Arduino must be loaded with the Standard Firmata sketch available in the Arduino examples.</p>
|
||||||
<p>You can select Digital, Analogue (PWM) or Servo type outputs. Expects a numeric value in <b>msg.payload</b>. The pin number is set in the properties panel.</p>
|
<p>You can select Digital, Analogue (PWM) or Servo type outputs. Expects an integer numeric value in <b>msg.payload</b>. The pin number is set in the properties panel.</p>
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
@ -138,13 +138,13 @@ module.exports = function(RED) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (node.state === "PWM") {
|
if (node.state === "PWM") {
|
||||||
msg.payload = msg.payload * 1;
|
msg.payload = parseInt((msg.payload * 1) + 0.5);
|
||||||
if ((msg.payload >= 0) && (msg.payload <= 255)) {
|
if ((msg.payload >= 0) && (msg.payload <= 255)) {
|
||||||
node.board.analogWrite(node.pin, msg.payload);
|
node.board.analogWrite(node.pin, msg.payload);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (node.state === "SERVO") {
|
if (node.state === "SERVO") {
|
||||||
msg.payload = msg.payload * 1;
|
msg.payload = parseInt((msg.payload * 1) + 0.5);
|
||||||
if ((msg.payload >= 0) && (msg.payload <= 180)) {
|
if ((msg.payload >= 0) && (msg.payload <= 180)) {
|
||||||
node.board.servoWrite(node.pin, msg.payload);
|
node.board.servoWrite(node.pin, msg.payload);
|
||||||
}
|
}
|
||||||
|
@ -1,20 +1,17 @@
|
|||||||
node-red-node-arduino
|
node-red-node-arduino
|
||||||
=====================
|
=====================
|
||||||
|
|
||||||
A <a href="http://nodered.org" target="_new">Node-RED</a> node to talk to an Arduino running firmata.
|
A <a href="http://nodered.org" target="_new">Node-RED</a> node to talk to an
|
||||||
|
Arduino running standard firmata 2.2 or better.
|
||||||
**Note** : This is the same node as was in the core of Node-RED.
|
|
||||||
As of v0.10.8 you will need to install it from here if still required.
|
|
||||||
|
|
||||||
Install
|
Install
|
||||||
-------
|
-------
|
||||||
|
|
||||||
Run the following command in the root directory of your Node-RED install, usually
|
Run the following command in the root directory of your Node-RED install, usually
|
||||||
this is ~/.node-red .
|
this is `~/.node-red`
|
||||||
|
|
||||||
npm install node-red-node-arduino
|
npm install node-red-node-arduino
|
||||||
|
|
||||||
|
|
||||||
Usage
|
Usage
|
||||||
-----
|
-----
|
||||||
|
|
||||||
@ -23,23 +20,33 @@ The Firmata firmware must be loaded into the Arduino.
|
|||||||
See the [main documentation](http://nodered.org/docs/hardware/arduino.html) for
|
See the [main documentation](http://nodered.org/docs/hardware/arduino.html) for
|
||||||
details and examples of how to use this node.
|
details and examples of how to use this node.
|
||||||
|
|
||||||
###Input Node
|
### Input Node
|
||||||
|
|
||||||
Connects to local Arduino and monitors the selected pin for changes.
|
Connects to local Arduino and monitors the selected pin for changes.
|
||||||
|
|
||||||
You can select either Digital or Analogue input. Outputs the value read as **msg.payload** and the pin number as **msg.topic**.
|
You can select either **Digital** or **Analogue** input type.
|
||||||
|
Outputs the value read as **msg.payload** and the pin number as **msg.topic**.
|
||||||
|
|
||||||
It only outputs on a change of value - fine for digital inputs, but you can get a lot of data from analogue pins which you must then handle.
|
It only outputs on a change of value - fine for digital inputs, but you can get a lot of data from analogue pins which you must then handle.
|
||||||
|
|
||||||
You can set the sample rate in ms from 20 to 65535.
|
You can set the sample rate from `20` to `65535` mS.
|
||||||
|
|
||||||
###Output Node
|
### Output Node
|
||||||
|
|
||||||
Connects to local Arduino and writes to the selected pin.
|
Connects to local Arduino and writes to the selected pin.
|
||||||
|
|
||||||
You can select Digital, Analogue (PWM) or Servo type outputs. Expects a numeric value in **msg.payload**. The pin number is set in the properties panel.
|
You can select
|
||||||
|
|
||||||
###Example
|
- **Digital** - accepts 0, 1, true, false, on, off
|
||||||
|
- **Analogue** (PWM) - accepts Integer 0 to 255
|
||||||
|
- **Servo** - accepts Integer 0 - 180
|
||||||
|
|
||||||
|
Expects a numeric value in **msg.payload**. The pin number is set in the properties panel.
|
||||||
|
|
||||||
|
*Note* - some servos will not travel a full 180 degree range so may only accept 30 - 150 degrees for example.
|
||||||
|
Please use the `range` node to scale the input appropriately.
|
||||||
|
|
||||||
|
### Example
|
||||||
|
|
||||||
Simple flow to blink Pin 13
|
Simple flow to blink Pin 13
|
||||||
|
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
{
|
{
|
||||||
"name" : "node-red-node-arduino",
|
"name" : "node-red-node-arduino",
|
||||||
"version" : "0.0.2",
|
"version" : "0.0.3",
|
||||||
"description" : "A Node-RED node to talk to an Arduino running firmata",
|
"description" : "A Node-RED node to talk to an Arduino running firmata",
|
||||||
"dependencies" : {
|
"dependencies" : {
|
||||||
"arduino-firmata" : "0.3.2"
|
"arduino-firmata" : "0.3.3"
|
||||||
},
|
},
|
||||||
"repository" : {
|
"repository" : {
|
||||||
"type":"git",
|
"type":"git",
|
||||||
|
Loading…
Reference in New Issue
Block a user