当前位置:网站首页>arduino获取随机数
arduino获取随机数
2022-07-06 09:16:00 【一入极客深似海】
使用 randomSeed()函数来读取一个未被使用到的引脚,
randomSeed(analogRead(A0)); //使用一个未被使用到的引脚
使用 random()函数来生成随机数,返回 long型
random()函数有两种使用使用方法
random(max); //返回数类型不会 超过所填的数据
random(min,max); //产生一个范围内的随机数
使用示例
void setup() {
Serial.begin(9600);
randomSeed(analogRead(A0)); //使用一个未被使用到的引脚
Serial.println(random(100));
Serial.println(random(100,300));
}
void loop(){
}
边栏推荐
- 分布式節點免密登錄
- encoderMapReduce 随手记
- 分布式节点免密登录
- [yarn] CDP cluster yarn configuration capacity scheduler batch allocation
- MySQL and C language connection (vs2019 version)
- 选择法排序与冒泡法排序【C语言】
- FTP file upload file implementation, regularly scan folders to upload files in the specified format to the server, C language to realize FTP file upload details and code case implementation
- There are three iPhone se 2022 models in the Eurasian Economic Commission database
- Basic use of pytest
- Nodejs connect mysql
猜你喜欢
随机推荐
Kaggle竞赛-Two Sigma Connect: Rental Listing Inquiries
Redis面试题
2020 WANGDING cup_ Rosefinch formation_ Web_ nmap
【presto】presto 参数配置优化
MongoDB
小L的试卷
nodejs连接Mysql
Solution of deleting path variable by mistake
分布式节点免密登录
FTP file upload file implementation, regularly scan folders to upload files in the specified format to the server, C language to realize FTP file upload details and code case implementation
[yarn] CDP cluster yarn configuration capacity scheduler batch allocation
Using LinkedHashMap to realize the caching of an LRU algorithm
Raspberry pie tap switch button to use
Gallery's image browsing and component learning
When using lambda to pass parameters in a loop, the parameters are always the same value
Implementation scheme of distributed transaction
MATLAB学习和实战 随手记
[Bluebridge cup 2021 preliminary] weight weighing
第4阶段 Mysql数据库
Togglebutton realizes the effect of switching lights