Fab Academy 第十六周:界面和應用編程
這周學習界面和應用編程
實踐作業
這周的作業是
為輸入/輸出設備寫一個應用程序
為之前做的這個檢測光線的板子做個小應用好了。
先試著讓板子跟串口通訊,看看元件是不是正常傳送檢測值。
#include "SoftwareSerial.h"n nconst int analogInPin = A3; // Analog input pin that the potentiometer is attached tonint sensorValue = 0; // value read from the potn nconst int Rx = 2; // this is physical pin 7nconst int Tx = 7; // this is physical pin 6nSoftwareSerial mySerial(Rx, Tx);n nvoid setup() {n pinMode(Rx, INPUT);n pinMode(Tx, OUTPUT);n mySerial.begin(9600); // send serial data at 9600 bits/secn}nnvoid loop(){n sensorValue = analogRead(analogInPin);n mySerial.println(sensorValue);n delay(500);n}n
光電晶體管工作正常。
Video
下一步,在 processing 裡面寫界面的程序。當檢測到光線變暗時,界面提示 「-_- Its dark!」 ,如果光線變亮,提示 「its getting light 」:
The code:
import processing.serial.*;nSerial myPort;nint lf = 10;n nvoid setup(){n size(300,300);n myPort = new Serial(this,"/dev/tty.usbserial-A400gwhT",9600);n textAlign(CENTER, CENTER);n fill(255);n textSize(20);n}n nvoid draw(){n while(myPort.available() > 0){n String str = myPort.readStringUntil(lf);nn if(str!=null){n int value = Integer.parseInt(trim(str));n n if (value >900) {n print("its dark ");n println(value);n background(0,0,0);n text("-_- Its dark! ",150,120);n text(value,150,200);n } n else{n print("its getting light ");n println(value);n background(204,153,0);n text(":P Its getting light ",150,120);n text(value,150,200);n }n }n }n}n
Video
課堂筆記
編程語言
- hello world
- C, GCC, C++, GDB (debugger), DDD (graphical viewer)
- Java, OpenJDK, IcedTea, Scala, Android
- Haskell
- Processing, Wiring, Arduino
- data flow: LabVIEW, Simulink, Max (for music), Pd, Scratch (for kids), App Inventor, Grasshopper, Firefly
- Bash, Tcl
- Interpretive language: Python, tutorial, Perl, Ruby
- JavaScript, JavaScript, Node.js, V8 (Google Chrome), npm (package manager for node), npm, WebAssembly (compile js)
- APL
設備介面
- for serial communication: RS/EIA/TIA 232/422/485, pySerial, serialport, serialport
- USB - serial:FTDI, libFTDI, python-ftdi, node ftdi lib
- USB, PyUSB, node usb lib
- IrDA, python-irda
- GPIB, VISA, PyVISA: Control your instruments with Python — PyVISA 1.8 documentation
- IOT: MQTT, XMPP
- Native netwrok interface: socket, dgram, net, node websocket package
數據介面
- sheet: Calc, Sheets
- py sheet: Pyspread, Pandas
- MySQL, MongoDB
用戶界面
- Tk, Tkinter: hello.load.45.py
- wxWidgets, wxPython: ef="http://kokompe.cba.mit.edu/index.html">panelpngpath.py
- Qt (antimony), PyQt
- GTK, PyGTK
- PyGTK, PyClutter
- Kivy(cross platform)
- forms, forms
- Framworks: Require, Require, Angular, Angular, Ember, Ember, Meteor, Babel
圖形
- low level: X Windows
- java: AWT, JFC, Swing
- Canvas
- SVG
- 3D graphics: WebGL, Three.js
- OpenGL, GLUT, GLUT
- CG: RenderMan, RenderMan, Pixie
- complex data: VTK, pyvtk, pyvtk
- 3D BIO data: OpenVDB
- Game engine: Unity
- GPU: CUDA, OpenCL
多媒體
- SDL, Pygame
- openFrameworks, ofpython
- HTML5, WebRTC (realtime audio & video)
數學
- SciPy, NumPy, IPython, Jupyter
- low level lib: Netlib, BLAS, LINPACK, LAPACK
- MATLAB, Octave
- matplotlib, Seaborn
- R, RPy, ggplot2
- symbolic: Mathematica, Mathematica, SymPy
- typed arrays, web workers, file reader
- Math.js, Math.js, Science.js
- jqPlot, D3, Highcharts
- signal processing, modeling
課程資源
- Fab Academy 2016 課表
- Week16 課程視頻
- Week16 課程大綱
- 我的英文筆記 Gitbook
- 公眾號文章列表
專欄文章
Fab Academy 第一周:怎樣在一周內建好自己的網站
Fab Academy 第二周:CAD 三維設計
Fab Academy 第三周:機器切割
Fab Academy 第四周:製作電路板
Fab Academy 第五周:3D 掃描和列印
Fab Academy 第六周:電路設計基礎
Fab Academy 第七周:數控機器
Fab Academy 第八周:嵌入式編程
Fab Academy 第九周:機械設計
Fab Academy 第十周:機器設計
Fab Academy 第十一周:輸入設備
Fab Academy 第十二周:模具和鑄件
Fab Academy 第十三周:輸出設備
Fab Academy 第十四周:合成材料
Fab Academy 第十五周:網路和通信
推薦閱讀:
※Haskell 這段代碼該如何理解?
※設計師學編程?從五個思維訓練開始
※getter 和 setter 方法有什麼意義?
※我們為什麼需要React?