量:
結構
數字
I/O
模擬
I/O
- int analogRead(pin) 類比IO口讀函數,pin表示為0~5(Arduino Diecimila為0~5,Arduino nano為0~7)。比如可以讀模擬感測器(10位AD,0~5V表示為0~1023)。
- analogWrite(pin, value) - PWM 數位IO口PWM輸出函數,Arduino數位IO口標注了PWM的IO口可使用該函數,pin表示3, 5, 6, 9, 10, 11,value表示為0~255。比如可用於電機PWM調速或音樂播放。
擴展
I/O
- shiftOut(dataPin, clockPin, bitOrder, value) SPI外部IO擴展函數,通常使用帶SPI介面的74HC595做8個IO擴展,dataPin為資料口,clockPin為時鐘口,bitOrder為資料傳輸方向(MSBFIRST高位在前,LSBFIRST低位在前),value表示所要傳送的資料(0~255),另外還需要一個IO口做74HC595的使能控制。
- unsigned long pulseIn(pin, value) 脈衝長度記錄函數,返回時間參數(us),pin表示為0~13,value為HIGH或LOW。比如value為HIGH,那麼當pin輸入為高電平時,開始計時,當pin輸入為低電平時,停止計時,然後返回該時間。
時間函數
數學函數
三角函數
亂數函數
外部中斷函數
- attachInterrupt(interrupt, , mode) 外部中斷只能用到數字IO口2和3,interrupt表示中斷口初始0或1,表示一個功能函數,mode:LOW低電平中斷,CHANGE有變化就中斷,RISING上升沿中斷,FALLING 下降沿中斷。
中斷使能函數
- interrupts() 使能中斷
- noInterrupts() 禁止中斷
串口收發函數
- int Serial.available() 判斷緩衝器狀態。
- int Serial.read() 讀串口並返回收到參數。
- Serial.flush() 清空緩衝器。
- Serial.print(data) 串口輸出資料。
- Serial.println(data) 串口輸出資料並帶回車符。
/************Arduino語言庫檔*************/
官方庫文件
非官方庫文件
- DateTime - a library for keeping track of the current date and time in software.日期與時間
- Debounce - for reading noisy digital inputs (e.g. from buttons)
- Firmata - for communicating with applications on the computer using a standard serial protocol.
- GLCD - graphics routines for LCD based on the KS0108 or equivalent chipset.
- LCD - control LCDs (using 8 data lines)
- LCD 4 Bit - control LCDs (using 4 data lines)
- LedControl - for controlling LED matrices or seven-segment displays with a MAX7221 or MAX7219.
- LedControl - an alternative to the Matrix library for driving multiple LEDs with Maxim chips.
- Messenger - for processing text-based messages from the computer
- Metro - help you time actions at regular intervals
- MsTimer2 - uses the timer 2 interrupt to trigger an action every N milliseconds.
- OneWire - control devices (from Dallas Semiconductor) that use the One Wire protocol.
- PS2Keyboard - read characters from a PS2 keyboard.
- Servo - provides software support for Servo motors on any pins.
- Servotimer1 - provides hardware support for Servo motors on pins 9 and 10
- Simple Message System - send messages between Arduino and the computer
- SSerial2Mobile - send text messages or emails using a cell phone (via AT commands over software serial)
- TextString - handle strings
- TLC5940 - 16 channel 12 bit PWM controller.
- X10 - Sending X10 signals over AC power lines
/****************************************/
沒有留言:
張貼留言