arduino

DS18B20温度传感器知识点总结

可紊 提交于 2020-12-19 08:56:19
2018-01-1818:20:48 感觉自己最近有点凌乱,一个很简单的问题都能困扰自己很久。以前能很好使用和调试的DS18B20温度传感器,今天愣是搞了很久,妈卖批。 仅仅一个上拉电阻就困扰了我很久,同时也颠覆了我一直以来“电阻”无用的理论。有一些敏感元件,电阻的作用不容小觑。 调试代码简单精简版本如下,极客工坊大神修改版 1 #include " DS18B20_S.h " 2 // 传感器设定为10位模式,每次转换时间<187.5ms,如果需要12位模式,请修改库文件of ds.set(0x7F); 3 DS18B20_S ds( 9 ); // pin9 4 void setup() { 5 Serial.begin( 9600 ); 6 } 7 void loop() { 8 ds.start(); // 开始测量(所有传感器) 9 float a=ds. get (); 10 delay( 200 ); // 2根线连接模式 11 Serial.print( " c0= " ); 12 if (a> 200 ){ // CRC 校验错误 13 Serial.println( " CRC error " ); 14 } 15 else { 16 Serial.println(a); 17 } 18 19 // 下面的不重要 20 // void set(byte n);

esp32(M5STACK) ARDUINO开发环境搭建(ubuntu)

↘锁芯ラ 提交于 2020-12-19 06:54:24
首先去官网下载arduino https://www.arduino.cc/en/main/software 由于国产链接下载慢的缘故,所以可以采用百度网盘的方式进行下载,具体下载方法不赘述 下载完成后可以看到我们下载的文件 然后解压文件 xz -d arduino-1.8.8-linux64.tar.xz tar -xf arduino-1.8.8-linux64.tar 解压完成后可以看到解压出来的文件 进入arduino-1.8.8文件夹中,输入./install.sh开始安装 同时在桌面上可以看到图标 启动后效果如下: 接着,我们选择项目-->加载库-->管理库,搜索m5stack 此时,我们可以在文件->示例->不相容中找到我们m5stack开发板 现在,我们来体验一下,下载一个游戏 在编译下载之前,我们需要在工具->端口里设置我们的串口端口,我的是/dev/ttyUSB0 然后下载esp32的audrino库 git clone git@github.com:espressif/arduino-esp32.git 如果没有这个,将会使得很多的头文件都找不到,所以一定需要下载这个开发板包 下载完成后,将arduino-esp32文件夹重命名esp32 需要将esp32转移arduino-1.8.8/hardware/espressif/文件夹中

arduino雨滴传感器

爱⌒轻易说出口 提交于 2020-12-17 01:04:49
https://blog.csdn.net/yichu5074/article/details/81074055 功能介绍: 接上5V电源,电源指示灯亮,感应板上没有水滴时,DO输出为高电平,开关指示灯灭 ,滴上一滴水,DO输出为低电平,开关指示灯亮, 刷掉上面的水滴,又恢复到,输出高电平状态。。。。 AO模拟输出,可以连接单片机的AD口检测滴在上面的雨量大小。 DO TTL数字输出也可以连接单片机检测是否有雨。 接线方式: 1、VCC:接电源正(3-5V) 2、GND:接电源负 3、DO:TTL开关信号输出 4、AO:模拟信号输出 调节旋钮 改变出发阈值 例如在 735的时候调节阈值切换0-1 0-1023 #define yudi_d 2 void setup(){ Serial.begin(9600); pinMode(A7,INPUT); pinMode(yudi_d,INPUT); } void loop(){ int a0= analogRead(A7); Serial.print(a0); Serial.print("--"); int d2=digitalRead(yudi_d);//读取按键状态并储存在变量中 Serial.println(d2); delay(100); }    来源: oschina 链接: https://my.oschina.net/u

ESP8266 ESP-01 not show data from server in Arduino IDE serial monitor

本小妞迷上赌 提交于 2020-12-15 19:34:56
问题 i am new in arduino and ESP8266 module AT commands. I still learn about how to receive data from server and it show the data in Arduino serial monitor. I will tell you how i do and i hope someone will tell me what's wrong with my code or if any mistake that i have done. This is my php code in server side. Just a simple coding. I save it as index.php : <?php ECHO $_GET['subject']; ?> This is my AT commands in Arduino IDE serial monitor. AT+CIPSTART="TCP","nyalalampu.atwebpages.com",80 CONNECT

Ardunio 下的stm32f103指南者串口通信

二次信任 提交于 2020-12-15 15:12:03
Ardunio IDE完成stm32f103指南者的串口通信 1.用Ardunio IDE完成stm32f103指南者的串口通信。 安装Ardunio IDE 配置Ardunio IDE 连接stm32f103指南者开发板 烧录程序(stm32f103指南者) 2.基于标准库函数与基于HAL库函数的stm32编程方式的差异。 3.stduino IDE使用体会 4.参考文章: 1.用Ardunio IDE完成stm32f103指南者的串口通信。 安装Ardunio IDE 链接: Ardunio IDE相关包 . 提取码:q251 下载解压后安装Ardunio,一直默认安装就可以,选择路径的话注意不要有中文。 配置Ardunio IDE 将打包文件中的Arduino_STM32整个文件夹拷贝到Arduino安装目录下的hareware下。 然后打开Arduino,点击菜单栏\工具\开发板…\第一栏的开发板管理器 输入ARM关键字搜索,选中Cortex-M3系列的编译支持文件并安装,安装过程可能需要几分钟。 安装完成后,在菜单栏\工具\开发板选择芯片类型,由于我使用的是stm32f103指南者,所以选择为Generic STM32F103V series。 然后Variant,Upload method,CPU Speed,Optimize这几个的选择如下:

Arduino+nRF24L01多按键远程无线控制(接收端)

为君一笑 提交于 2020-12-15 15:09:46
Arduino+nRF24L01多按键远程无线控制(接收端) 可以去掉相关的String库和定义参数,本文没有采用。 接收按键1的的代码为51和24,分别对应的发射端的发送数据是123和456,跟换发送数据,对应的接收数值也会变化,这点注意!!定义的数据类型为byte。不知道为什么会这样? 如果定义的发送数据类型为char类型的话,就没有问题,但是如果是char数据类型,能接收到一致的数据,并从串口打印出来,但是不知道为什么程序写的判断代码就是判断不了接收到的数据的一致性。通过串口看打印出来的收到的数据又是一致的。不知道是数据类型问题还是数据格式不对,没有搞懂这个问题。有知道的小伙伴,可以告诉一下我。 代码区: # include <SPI.h> # include <nRF24L01.h> # include <RF24.h> # include <String.h> # define LedPin 4 //LED灯 # define LedPin2 5 //LED灯 RF24 radio ( 7 , 8 ) ; const byte address [ 6 ] = "00001" ; String comdata = "" ; byte text ; void setup ( ) { while ( ! Serial ) ; pinMode ( LedPin , OUTPUT

Serial monitor showing unexpected input from Arduino Mega

↘锁芯ラ 提交于 2020-12-12 04:40:06
问题 I'm using an Arduino Mega to control a CS1237 ADC. I'm sending a signal to the clock pin and after each clock pulse, waiting 1ms and then reading the response, according to the datasheet I found (via https://github.com/SiBangkotan/CS1237-ADC-cpp-library). This seems to be working in some capacity, because when I do Serial.println() for each bit received, and for the resulting dataword, I get a 24 bit dataword that matches the 24 separate bits I got. However, when I take out the extra

Proper implementation of Timer1 for PWM generation

我的梦境 提交于 2020-12-06 12:22:35
问题 On the Atmel ATmega328P (datasheet), there are three timers available for PWM generation (timer0, timer1, and timer2). I already have what I need using the 8-bit timer2, I am just concerned with using different timer instad of timer2, because timer2 is used in various libraries, and I'd like to have more granularity. Thus I'd like to use the 16-bit timer1. Here is what I am using to generate a 25 kHz, variable duty cycle using timer2. For this example, lets consider a 35% duty cycle: void

How can i convert a uint32_t to a char* type

偶尔善良 提交于 2020-12-05 07:25:46
问题 Hello i am using an Arduino UNO with an adafruit shield to display score values but the function used to display scores only accepts char* values and the score itself can occupy up to 6 digits(000,000 to 999,999). i have tried using sprint() but i have had no luck since the screen will flicker like crazy. i believe the problem to be that chars only hold a certain number of bytes that could not fit a 32 bit int but i would think their is a way around this. draw text is the function used by the

How can i convert a uint32_t to a char* type

扶醉桌前 提交于 2020-12-05 07:24:38
问题 Hello i am using an Arduino UNO with an adafruit shield to display score values but the function used to display scores only accepts char* values and the score itself can occupy up to 6 digits(000,000 to 999,999). i have tried using sprint() but i have had no luck since the screen will flicker like crazy. i believe the problem to be that chars only hold a certain number of bytes that could not fit a 32 bit int but i would think their is a way around this. draw text is the function used by the