最新消息:

Arduino语法- 随机数

Arduino 少儿编程 1547浏览 0评论
Arduino语法参考

函数列表

  • randomSeed()
  • random()

randomSeed()函数说明

void randomSeed  ( unsigned int  seed   )

设置随机种子

可以用当前时间作为随机种子. 随机种子的设置对产生的随机序列有影响.

参数:

seed 随机种子 

random()函数说明

long random (long howbig)  

生成随机数

生成[0, howbig-1]范围的随机数.

参数:

howbig 最大值 



long random (long howsmall, long howbig)  

生成随机数

生成[howsmall, howbig-1]范围的随机数.

参数:

howsmall 最小值
howbig 最大值 

您必须 登录 才能发表评论!