GithubHelp home page GithubHelp logo

stevelin100132 / lego-nxt-remote Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mronemous/lego-nxt-remote

0.0 2.0 0.0 25.9 MB

Lego nxt remote using Phonegap, Angular, and Typescript.

JavaScript 9.58% ApacheConf 3.08% HTML 2.54% TypeScript 4.85% CSS 59.69% Arduino 1.36% Java 7.28% Objective-C 8.04% C 0.24% C++ 0.85% C# 2.49%

lego-nxt-remote's Introduction

lego-nxt-remote

Lego NXT remote using Phonegap, Angular, and Typescript.

The primary purpose of this project is to help teach children how to program. The javascript API allows easier access to robot programming without getting very low level. The firmware of the Lego NXT brick does not need to be changed to use the API.

To setup the project run the following commands:

git clone git://github.com/mronemous/lego-nxt-remote.git && cd lego-nxt-remote
npm install
bower install
grunt create:cordova

Import the android project (/build/cordova/platforms/android) with your favorite IDE.

To run the local file watches and also start a local webserver.

grunt serve

TODO: grunt build currently only handles web code. Ideally it would allow release / debug configurations to create platform artifacts.

API Documentation

Create a Brick

var mac = "XX:XX:XX:XX:XX:XX"; //Mac of your brick.
var brick = new Nxt.Brick();


var driveL = new Nxt.Motor();
var driveR = new Nxt.Motor();
var cameraLift = new Nxt.Motor();

var sonarFront = new Nxt.SonarSensor();
sonarFront.name = "Front";

var sonarBack = new Nxt.SonarSensor();
sonarBack.name = "Back";

var compass = new Nxt.CompassSensor();
compass.name = "Heading";

var touch = new Nxt.TouchSensor();
touch.name = "Pressed";

brick.portA = driveL;
brick.portB = cameraLift;
brick.portC = driveR;
brick.port1 = sonarFront;
brick.port2 = touch;
brick.port3 = sonarBack;
brick.port4 = compass;

Connect to Brick

brick.connect(mac, function() {
  //connected
},
function(){
  //error connecting
});

Disconnect from Brick

brick.disconnect(mac, function() {
  //disconnected
},
function(){
  //error disconnecting
});

Write to a Motor

driveL.power = 100;
driveL.mode = Nxt.Motor.Modes.On;
driveL.regulation = Nxt.Motor.Regulation.None;
driveL.write(false);

Read a Sensor

compass.read(Nxt.CompassSensor.Registers.Degree, function(reading) {
  //Reading obtained by sensor.
},
function() {
  //Failed to get a reading from the sensor.
});

Play tone

brick.playTone(frequency, duration);

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

lego-nxt-remote's People

Watchers

 avatar  avatar

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.