分享一下我老师大神的人工智能教程!零基础,通俗易懂!http://blog.csdn.net/jiangjunshow
<https://blog.csdn.net/jiangjunshow/article/details/77338485>



也欢迎大家转载本篇文章。分享知识,造福人民,实现我们中华民族伟大复兴!


               
淘宝店铺:http://robotstudio.taobao.com <http://robotstudio.taobao.com/> 
群号: 259189548 




Arduino语言注解Arduino语言是建立在C/C++基础上的,其实也就是基础的C语言,Arduino语言只不过把AVR单片机(微控制器)相关的一些参数设置都函数化,不用我们去了解他的底层,让我们不了解AVR单片机(微控制器)的朋友也能轻松上手。
       在与Arduino
DIYER接触的这段时间里,发现有些朋友对Arduino语言还是比较难入手,那么这里我就简单的注释一下Arduino语言(本人也是半罐子水,有错的地方还请各位指正)。

 

关键字:
if
if...else
for
switch case
while
do... while
break
continue
return
goto
语法符号:
;
{}
//

运算符:
=
+
-
*
/
%
==
!=
<
>
<=
>=
&&
||
!
++
--
+=
-=
*=
/=
数据类型:
boolean  布尔类型
char
byte  字节类型
int
unsigned int
long
unsigned long
float
double
string
array
void
数据类型转换:
char()
byte()
int()
long()
float()
常量:
HIGH | LOW     表示数字IO口的电平,HIGH 表示高电平(1),LOW 表示低电平(0)。
INPUT | OUTPUT   表示数字IO口的方向,INPUT 表示输入(高阻态),OUTPUT  表示输出(AVR能提供5V电压 40mA电流)。
true | false    true 表示真(1),false表示假(0)。


       以上为基础c语言的关键字和符号,有c语言基础的都应该了解其含义,这里也不作过多的解释。

 

结构
void setup()   初始化变量,管脚模式,调用库函数等
void loop()  连续执行函数内的语句
功能
数字 I/O

pinMode(pin, mode)    数字IO口输入输出模式定义函数,pin表示为0~13, mode表示为INPUT或OUTPUT。
digitalWrite(pin,
value)    数字IO口输出电平定义函数,pin表示为0~13,value表示为HIGH或LOW。比如定义HIGH可以驱动LED。
int digitalRead(pin)    数字IO口读输入电平函数,pin表示为0~13,value表示为HIGH或LOW。比如可以读数字传感器。
模拟 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输入为低电平时,停止计时,然后返回该时间。
时间函数

unsigned long millis()   返回时间函数(单位ms),该函数是指,当程序运行就开始计时并返回记录的参数,该参数溢出大概需要50天时间。
delay(ms)    延时函数(单位ms)。
delayMicroseconds(us)    延时函数(单位us)。
数学函数

min(x, y)  求最小值
max(x, y)  求最大值
abs(x)   计算绝对值
constrain(x, a, b)  约束函数,下限a,上限b,x必须在ab之间才能返回。
map(value, fromLow, fromHigh, toLow,
toHigh)    约束函数,value必须在fromLow与toLow之间和fromHigh与toHigh之间。
pow(base, exponent)  开方函数,base的exponent次方。
sq(x)     平方
sqrt(x)   开根号
三角函数

sin(rad)
cos(rad)
tan(rad)
随机数函数

randomSeed(seed)   随机数端口定义函数,seed表示读模拟口analogRead(pin)函数 。
long random(max)   随机数函数,返回数据大于等于0,小于max。
long random(min, max)   随机数函数,返回数据大于等于min,小于max。
外部中断函数

attachInterrupt(interrupt, ,
mode)     外部中断只能用到数字IO口2和3,interrupt表示中断口初始0或1,表示一个功能函数,mode:LOW低电平中断,CHANGE有变化就中断,RISING上升沿中断,FALLING
下降沿中断。
detachInterrupt(interrupt)    中断开关,interrupt=1 开,interrupt=0 关。
中断使能函数

interrupts()  使能中断
noInterrupts()  禁止中断
串口收发函数

Serial.begin(speed)  串口定义波特率函数,speed表示波特率,如9600,19200等。
int Serial.available()  判断缓冲器状态。
int Serial.read()   读串口并返回收到参数。
Serial.flush()    清空缓冲器。
Serial.print(data)  串口输出数据。
Serial.println(data)   串口输出数据并带回车符。


 

官方库文件
EEPROM - EEPROM读写程序库
Ethernet - 以太网控制器程序库
LiquidCrystal - LCD控制程序库
Servo - 舵机控制程序库
SoftwareSerial - 任何数字IO口模拟串口程序库
Stepper - 步进电机控制程序库
Wire - TWI/I2C总线程序库
Matrix - LED矩阵控制程序库
Sprite - LED矩阵图象处理控制程序库
非官方库文件
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


以上库文件都需要下载到编译环境(如下目录:arduino-0011\hardware\libraries)中才能使用。

 
           


给我老师的人工智能教程打call!http://blog.csdn.net/jiangjunshow
<https://blog.csdn.net/jiangjunshow/article/details/77338485>

友情链接
ioDraw流程图
API参考文档
OK工具箱
云服务器优惠
阿里云优惠券
腾讯云优惠券
华为云优惠券
站点信息
问题反馈
邮箱:ixiaoyang8@qq.com
QQ群:637538335
关注微信