Giter Club home page Giter Club logo

nodejs_yun_example's Introduction

#NodeJS and Yun

Example code for running a NodeJS on the Arduino Yun.

The example runs an HTTP server on the Yun at port 8000. The webpage it serves will send a websocket message to the server when the mouse is clicked. This will turn the RGB LED to a random color, and send that color back to webpage to be dispayed.

##Install

See THIS TUTORIAL for how to install NodeJS on the Yun, and set the board up to be used without Arduino's Bridge libary.

###Arduino

For this example, I used an RGB led plugged into digital pins 3-6. Ground in pin 4, red is pin 3, green is pin 5, and blue is pin 6.

Upload the code rgb_arduino sketch to the board. If using the Yun, be sure to use Serial1 instead of Serial.

###NodeJS

Inside app.js, be sure serialport is using the corrent port name to connect to. These can be different depending on the computer, but the Yun always uses port "/dev/ttyATH0".

####On a Laptop

npm install
node app.js

Upen and edit 'app.js' to change the 'myPortName' variable to be whatever port your Arduino is currently connected to;

####On the Yun

Be sure have installed the following modules using the Yun's package manager:

opkg update
opkg install node-ws
opkg install node-serialport

Upen and edit 'app.js' to change the 'myPortName' variable to be "/dev/ttyATH0";

When running, place only app.js and index.html on the Yun. All other files are not needed, since node-modules are installed globally on the Yun.

nodejs_yun_example's People

Contributors

andysigler avatar

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.