Arduino
arduino开发板
-
数字输入输出端口Dn,TX1,RX0
输入输出数字信号0,1。
TX1,RX0,用于与电脑进行数据传输。
使用数字端口前要声明数字端口是输入还是输出。
-
模拟输入输出端口An
pwm的应用
-
电源端口
Arduino程序介绍
1.基本程序框架
void setup() {
// put your setup code here, to run once:
}
void loop() {
// put your main code here, to run repeatedly:
}
2.变量
变量类型
-
int
int a = 0; //creates a variable integer called 'a' void setup() { Serial.begin(9600); // use the serial port to print the number } void loop() { a++; //Adds 1 to the a int on every loop Serial.println(a); // prints out the current state of a delay(1000); }
-
double
-
float
float myfloat; float sensorCalbrate = 1.117; int x; int y; float z; x = 1; y = x / 2; // y now contains 0, ints can't hold fractions z = (float)x / 2.0; // z now contains .5 (you have to use 2.0, not 2)
-
string
char Str1[15]; char Str2[8] = {'a', 'r', 'd', 'u', 'i', 'n', 'o'}; char Str3[8] = {'a', 'r', 'd', 'u', 'i', 'n', 'o', '\0'}; char Str4[] = "arduino"; char Str5[8] = "arduino"; char Str6[15] = "arduino"; /************************************************************************************/ char *myStrings[] = {"This is string 1", "This is string 2", "This is string 3", "This is string 4", "This is string 5", "This is string 6" }; void setup() { Serial.begin(9600); } void loop() { for (int i = 0; i < 6; i++) { Serial.println(myStrings[i]); delay(500); } }