2015年12月10日 星期四

C語言巨集定義技巧

轉載自:
http://miaozl.spaces.live.com/?_c11_blogpart_blogpart=blogview&_c=blogpart&_c02_owner=1&partqs=amonth%3d2%26ayear%3d2007


C語言巨集定義技巧
1,防止一個頭檔被重複包含 

#ifndef COMDEF_H

#define COMDEF_H

//頭檔內容

#endif 

2,重新定義一些類型,防止由於各種平臺和編譯器的不同,而產生的類型位元組數差異,方便移植。 

2015年11月11日 星期三

[Arduino]參考資料

[Arduino] setup() loop() 不在*.ino草稿檔中,如何做?

一般而言在Arduino中,開啟新檔後,就會在其INO檔中看到setup()及loop()這二個函數

例如:
Blink.ino 內容如下:
void setup() {
  // initialize digital pin 13 as an output.
  pinMode(13, OUTPUT);
}

void loop() {
  digitalWrite(13, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);              // wait for a second
  digitalWrite(13, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);              // wait for a second
}

本文打算要來把setup和loop這二個函數搬位置,應該如何實現呢?
在開啟新的arduino檔案時,會有一個INO檔
我們可以加入其它的檔案,如*.h的標頭檔,或是*.cpp的檔

2015年11月8日 星期日

RamPs1.4 基本組裝與步進馬達測試

RamPs1.4 基本組裝與步進馬達測試
1、安裝好Arduino IDE程式,並裝好Aduino Mega 2560的驅動程式
2、將RamPs1.4模組組裝到Mega 2560上,並將RamPs1.4上的步進馬達Jumpper選擇至所需的檔位
3、插入A4988步進馬達驅動器組裝至RamPs1.4上。請注意方向

2015年11月1日 星期日

[Arduino] 指令表 (出自於www.arduino.cc)

出處:https://www.arduino.cc/en/Reference/HomePage

Structure

Control Structures

Further Syntax

Arithmetic Operators

  • = (assignment operator)
  •  (addition)
  • - (subtraction)
  • * (multiplication)
  • / (division)
  • % (modulo)

Comparison Operators

  • == (equal to)
  • != (not equal to)
  • < (less than)
  • > (greater than)
  • <= (less than or equal to)
  • >= (greater than or equal to)

Boolean Operators

  • && (and)
  • || (or)
  • ! (not)

Pointer Access Operators

Bitwise Operators

  • & (bitwise and)
  • | (bitwise or)
  • ^ (bitwise xor)
  • ~ (bitwise not)
  • << (bitshift left)
  • >> (bitshift right)

Compound Operators

  • ++ (increment)
  • -- (decrement)
  • += (compound addition)
  • -= (compound subtraction)
  • *= (compound multiplication)
  • /= (compound division)
  • %= (compound modulo)
  • &= (compound bitwise and)
  • |= (compound bitwise or)

Variables

Constants

Data Types

Conversion

Variable Scope & Qualifiers

Utilities

Functions

Digital I/O

Analog I/O

Due & Zero only

Advanced I/O

Time

Math

Trigonometry

Characters

Random Numbers

Bits and Bytes

External Interrupts

Interrupts

Communication

USB (32u4 based boards and Due/Zero only)

2015年10月31日 星期六

[Arduino] C前置處理

 C 前置處理

對於一個 C 程式 編譯之前, C 編譯器 會先處理 C 程式 中含有
 #define、#undef、#if、#ifdef、#ifndef、#endif、#elif、#else 及 #include 敘述, 將之置換成一新 C 程式, 再將之編譯 成一 assembly 程式, 再轉成 machine code(或 object code)。 再經由 linker 變成一執行檔。