Giter Site home page Giter Site logo

learning-iot's Introduction

机器人爱 JavaScript

机器人爱 JavaScript 系列一

机器人爱 JavaScript 系列二

配置项目

  1. git clone https://github.com/Kennytian/learning-iot.git
  2. cd learning-iot & yarn
  3. 配置WebStorm + nodemon,在Node parameters里加入:/usr/local/bin/nodemon --exec /usr/local/bin/node

采购:

  1. Arduino UNO 开发板。刚开始学习只需买一块开发板即可,会送一根线,板载有 led 灯,淘宝一般在 30 块钱左右。
  2. Arduino 电子元件。随着后期深入学习,就自然明白需要什么元件,再买不迟。

环境:

  1. Mac、Windows、Linux 电脑均可(以后我以 Mac 电脑为开发环境)。
  2. 安装 Node 4.3.0 及以上版本,建议安装 LTS 版,下载地址 https://nodejs.org/en/download/
  3. 安装 Arduino 相应驱动,并重启电脑。具体驱动请自行搜索开发板型号+当前操作系统,如:ch340g mac。 如果你买的是Arduino UNO R3(CH340G)开发板,就下载 http://www.wch.cn/download/CH341SER_MAC_ZIP.html
  4. 安装 Arduino IDE 开发环境,下载地址:https://www.arduino.cc/en/main/software

开发板:

  1. 将 USB 数据线把电脑与开发板连接后,正常情况下你会在 Arduino IDE 上看到你开发板的端口,如图:

    arduino_port

    你开发板的端口很有可能与图中的端口不一样,但没有关系,只要识别出来就行。一般是:'/dev/cu.xxxusbxxx' 字样的标识。

  2. 打开 Arduino IDE, 选择: File > Examples > Firmata > StandardFirmataPlus,如图:

    standard_firemata_plus

  3. 在 Arduino IDE 界面点击 "上传" 按钮,如图:

    upload_firemata

第一个程序

  1. 新建一个目录,比如:firstIoT,在命令行下进入该目录,执行:npm install johnny-five
  2. 在 firstIot 里新建一个文件 led-blink.js,输入如下代码:
const { Board, Led } = require('johnny-five');
new Board().on('ready', function() {
  var led = new Led(13);
  led.blink(500);
});
  1. 在该目录下执行 node led-blink.js,如果程序不出错,就会出现下面的一闪一闪亮晶晶

    led_blink

----------------------------------推广分隔线----------------------------------

欢迎 QQ 群加入交流 700434239

QQ群

learning-iot's People

Stargazers

 avatar  avatar

Watchers

 avatar  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.