0.1.20 • Published 8 years ago

ir-sensor v0.1.20

Weekly downloads
1
License
MIT
Repository
github
Last release
8 years ago

ir-sensor

NPM version Code style

get values from ev3 ir-sensor

Installation

$ npm install ev3-js-ir-sensor

Usage

var IRSensor = require('ir-sensor')
IRSensor(3).proximity // => 50
IRSensor(3).beacon(2) // => { heading: 0, distance: 100 }
IRSensor(3).remote(3) // => 1

API

IRSensor(port)

  • port - number of the port that the IR sensor is connected to

Returns: instance of IRSensor

.proximity

get the distance from the IR sensor to the nearest obstacle

Returns: number between 0 and 100

.beacon(channel)

get the heading and distance to the beacon on the specified channel

Returns: object with heading and distance.

heading
valuestate
between 1 and 25beacon to the right
0beacon straight ahead (or no beacon)
between -25 and -1beacon to the left
distance
valuestate
between 0 and 100beacon distance
-128beacon not found

.remote(channel)

get the current state of the IR remote on the specified channel

Returns: number between 0 and 11

valuestate
0none
1red up
2red down
3blue up
4blue down
5red up and blue up
6red up and blue down
7red down and blue up
8red down and blue down
9beacon mode on
10red up and red down
11blue up and blue down

License

MIT

0.1.20

8 years ago

0.1.19

8 years ago

0.1.18

8 years ago

0.1.17

8 years ago

0.1.16

8 years ago

0.1.15

8 years ago

0.1.14

8 years ago

0.1.13

8 years ago

0.1.12

8 years ago

0.1.11

8 years ago

0.1.10

8 years ago