Giter Site home page Giter Site logo

nodeformegapi's Introduction

Node For MegaPi

How To Use

npm install megapi
  • Insert the initial code for starting MegaPi first.
var MegaPi = require("megapi").MegaPi;
var bot = new MegaPi("/dev/ttyS0", onStart); //"/dev/ttyAMA0" for rpi2, "/dev/ttyS0" for rpi3
function onStart(){
  //start your code
  setTimeout(loop,500);
}
var level = 0;
function loop(){
  bot.digitalWrite(13, level);
  level = 1-level;
  setTimeout(loop,500);
}
  • node your code

Node API

  • Start

    • MegaPi( serialport, function onStart)
  • GPIO

    • digitalWrite( pin, level )
    • pwmWrite( pin, pwm )
    • digitalRead( pin, function onResult )
    • analogRead( pin, function onResult )
  • Motion

    • DC Motor
      • dcMotorRun( port, speed )
    • Servo Motor
      • servoRun( port, slot, angle )
    • Encoder Motor
      • encoderMotorRun( port, speed )
      • encoderMotorMove( port, speed, distance, function onFinish )
      • encoderMotorMoveTo( port, speed, position, function onFinish )
    • Stepper Motor
      • stepperMotorSetting( port, microsteps, acceleration )
      • stepperMotorRun( port, speed )
      • stepperMotorMove( port, speed, distance, function onFinish )
      • stepperMotorMoveTo( port, speed, position, function onFinish )
  • Sensors

    • Ultrasonic Sensor
      • ultrasonicSensorRead ( port, function onResult )
    • LineFollow Sensor
      • lineFollowerRead ( port, function onResult )
    • Light Sensor
      • lightSensorRead ( port, function onResult )
    • Sound Sensor
      • soundSensorRead ( port, function onResult )
    • Temperature Sensor
      • temperatureRead ( port, function onResult )
    • PIR Motion Sensor
      • pirMotionSensorRead ( port, function onResult )
    • Touch Sensor
      • touchSensorRead ( port, function onResult )
    • LimitSwitch
      • limitSwitchRead ( port, slot, function onResult )
    • Humiture Sensor
      • humitureSensorRead ( port, type, function onResult )
    • Gas Sensor
      • gasSensorRead ( port, function onResult )
    • Flame Sensor
      • flameSensorRead ( port, function onResult )
    • Button
      • buttonRead ( port, function onResult )
    • Potentiometer
      • potentiometerRead ( port, function onResult )
    • Joystick
      • joystickRead ( port, axis, function onResult )
    • 3-Axis Accelerometer and Gyro Sensor
      • gyroRead ( axis, function onResult )
    • Compass
      • compassRead ( function onResult )
  • Display

    • RGB Led
      • rgbledDisplay ( port, slot, index, r, g, b )
      • rgbledShow ( port, slot )
    • 7-segment Display
      • sevenSegmentDisplay ( port, value )
    • Led Matrix Display
      • ledMatrixMessage ( port, x, y, msg )
      • ledMatrixDisplay ( port, x, y, buffer )
    • Serial LCD Display
      • lcdDisplay ( string )
  • Others

    • DSLR Shutter
      • shutterOn ( port )
      • shutterOff ( port )
      • focusOn ( port )
      • focusOff ( port )

Examples

https://github.com/Makeblock-official/NodeForMegaPi/tree/master/examples

###Learn more from Makeblock official website: www.makeblock.com

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.