來用 JavaScript 玩 Arduino 吧!



來用 JavaScript 玩 Arduino 吧!

0 0


play-javascript-on-arduino

A simple talk about play javascript on ardiuno

On Github Asoul / play-javascript-on-arduino

來用 JavaScript 玩 Arduino 吧!

http://asoul.github.io/play-javascript-on-arduino/

Created by Asoul @ WisdomGarden 2015.10.22

Rock it!

What is Arduino?

Arduino is an open-source electronics platform based on easy-to-use hardware and software.

Why Arduino?

Easy Inexpensive Open Source

JavaScript on Arduino

Install JonnyFive

npm install johnny-five

It works!

var five = require("johnny-five")
var board = new five.Board()

board.on("ready", function() {
  var led = new five.Led(13)
  led.blink(500)
})

PWM wave

PWM example

var brightness = 0
function controller(ch, key) {
  if (key) {
    if (key.name === "up") {
      brightness += 25
    }
    if (key.name === "down") {
      brightness -= 25
    }
    brightness = Math.max(brightness, 0)
    brightness = Math.min(brightness, 250)
    led.brightness(brightness)
  }
}
process.stdin.on("keypress", controller)

Piezo

Piezo example

var piezo = new five.Piezo(3)
piezo.play({
  song: "C D F D A - A A A A G G G G - - C D F D G - G G G G F F F F - -",
  beats: 1 / 4,
  tempo: 100
})

ESP8226

ONLY NTD$ 200

Sensor anywhere

  • Temperature
  • Humidity
  • Light
  • Sound
  • ...

Learn once, use everywhere

Reference

Thank you!

來用 JavaScript 玩 Arduino 吧! http://asoul.github.io/play-javascript-on-arduino/ Created by Asoul @ WisdomGarden 2015.10.22