亿迅智能制造网
工业4.0先进制造技术信息网站!
首页 | 制造技术 | 制造设备 | 工业物联网 | 工业材料 | 设备保养维修 | 工业编程 |
home  MfgRobots >> 亿迅智能制造网 >  >> Manufacturing Technology >> 制造工艺

Model Rail Digital DCC Command Station Arduino 和免费应用程序

组件和用品

SparkFun Arduino Pro Mini 328 - 5V/16MHz
× 1
LMD18200t
× 1
PCB
× 1
线性调节器 (7805)
× 1
3.6V 0.5W 齐纳二极管
× 1
电容 220 µF
16 伏
× 1
电容 10 µF
16 伏
× 1
陶瓷圆盘电容器,0.1 µF
× 3
电阻 10k ohm
× 2
通孔电阻,4.7 kohm
× 1
螺钉端子 2 位置 3.5 毫米中心,1.1 毫米针直径
× 1
螺钉端子 6 位置 2.54 毫米中心
× 1
4 针 2.54 毫米插座
× 1
12 针 2.54 毫米插座
× 2

应用和在线服务

LocoMotive
这是应用程序的免费版本
LocoMotive DCC
这是最新版本,包括 cv 1 到 255 的读/写

关于这个项目

这个系统有什么不同?
一个非常简单的电子电路为赛道提供 DCC 信号和电源,但应用程序可以真正发挥作用! 通过构建形成每个指令包所需的代码,充分利用手机上的计算机,从而简化 Arduino 控制器的工作!

2019 年 8 月 16 日更新:发布新的改进应用程序 - 具有读取/写入简历 1 至 255 的功能
此应用版本 售价为 5 英镑加税,可在 Google Play 商店购买。

2019 年 5 月 18 日更新:发布新的改进应用程序 - 多达 28 项功能,可编辑标题、可见性和瞬时选项。使用屏幕上的速度条同时控制多达 4 个机车。此应用版本 售价 3 英镑加税,可在 Google Play 商店购买。

2019 年 2 月 17 日更新:您可能需要修改 HC-06 蓝牙模块以扩展其接收范围。我添加了一根实心铜线(来自电源地线)31.2 毫米长(1/4 2.4 GHz 的波长)。请参阅步骤 2 中的附加照片。

2019 年 1 月 29 日更新:在 F2 和 F3 上为喇叭声音添加了瞬时选项为每个机车预设最大速度这是可能构建的最高效的 DCC 指挥站。没有其他系统可以用这么少的组件做这么多事情。一个易于组装的功能齐全的 DCC 指挥站,带有可在 eBay 上买到的 PCB,而且只需要几个零件。“LocoMotive”应用程序旨在在运行 4.1 及更高版本的 Android 手机上运行. 无需购买任何专有系统,这是一个独立的单元,由名为“LocoMotive”Works 的免费应用程序运行,带有 NMRA 兼容解码器。该系统编译 App 内的运行 DCC 数据包,这些数据包发送到 Arduino 接口以与 DCC 时钟信号结合。在 eBay 上购买此 PCB。在 Google Play Store 上获得免费的 App LocoMotive。功能包括:

  • 控制 1 到 20 个火车头
  • 非常适合中小型布局
  • 2 安培负载使用指定的 H 桥驱动多达 16 个 OO/HO 机车
  • 添加更高电流兼容的 h 桥以扩展负载能力
  • 短路保护
  • 自动过流切断,可在Arduino代码中调节
  • 灯光和方向
  • 函数 1 到 8
  • 编辑函数名称、可见性和瞬时动作
  • 道岔/点/附件操作多达 8 对输出
  • 编辑投票者名称
  • 自定义机车命名并为每个机车设置最大速度
  • 编写 CV1 本地地址
  • 读/写简历 1 到 255
  • 添加您自己的附件地址
  • 选择适合所用规模的直流电源 (Z/N/OO/HO/O/G) 12v 至 20v

继之前在 DCC 无线系统上的工作之后,我开发了一个蓝牙指挥站,链接到基于 Arduino 的接收器电路,带有 HC-06 BT 模块和 LMD18200 H 桥电机驱动器,可提供 2 安培。

从 eBay 购买零件的零件总成本约为 20 英镑。

第 1 步:Arduino 草图

附上完整的草图。这部分是循环和数据接收器代码。 Android App 向接收器发送一个完整的数据包,并在此处解码为数据数组。根据收到的是 3 字节还是 4 字节,代码将为火车轨道生成正确的 DCC 数据包格式。

void loop() {if(bluetooth.available()> 0); {inString =bluetooth.readStringUntil('\n');}if (inString.substring(0, 1)=="D") {string();}delay(20);}

string() void 然后从接收到的文本字符串中分离出数据,并将每条指令放置在 DCC 数据包中的适当位置。

例如:

接收到的文本字符串 'DD, 3, 63, 12, 48, ' 转换为一个 4 字节的 8 位速度数据包:

DD =消息 IDByte:[1] [2] [3] [4]Decimal:[3] [63] [12] [48] Binary:[0000 0011] [0001 1111] [0000 1100] [0001 1000] Action :[Loco 3] [速度步数] [ loco speed] [ XOR 数据校验]

接收到的文本字符串 'DD, 1, 129, 128, ' 转换为 3 字节的功能包,每个 8 位:十进制:[1] [129] [128] 二进制:[0000 0001] [1000 0001] [1000 0000] 动作:[Loco 1] [ F1 on] [XOR 数据检查]

更多NMRA数据包标准参考:https://www.nmra.org/sites/default/files/s-9.2.1_2...

s-9.2.1_2012_07.pdf

LMD 需要 DIR 引脚上的 DCC 信号和 PWM 引脚保持高电平。

command_station_bluetooth_oct_2018.ino

第 2 步:Fritzing 电路图

Arduino Pro Mini 通过 HC-06 模块接收蓝牙数据。 Arduino 生成数据包格式的 NMRA 标准时钟周期。当接收到新数据时,接收到的数据中断序列,更新DCC数据包以向列车轨道发送指令。

所需零件清单:

PCB 可在 eBay 上购买。

1 件 Arduino Pro Mini Atmega328P 5V/16M eBay

1 关 LMD18200T H 桥 eBay

1 关 HC-06 蓝牙模块 eBay

1 个 0.1 欧姆 2W 金属膜电阻器 0.1R 2 瓦特(11.5 毫米 x 4.5 毫米)易趣

3折电容0.1uf易趣

2 关 10kΩ 电阻 eBay

1 关闭电容器 10uf 25v;易趣

1 关闭电容器 220uf 16v;易趣

1 off Phoenix Contact MKDS 1/ 2-3, 5 2路螺丝PCB接线端子13.5A 200V 3.5mm eBay

1 个 4.7kΩ 电阻 eBay

1 个 L7805 CV 正电压稳压器 IC eBay

1 个 4 针母接头边缘销条 0.1" 2.54 毫米 eBay

2 个 12 针母接头边缘销条 0.1" 2.54 毫米 eBay

1 个 6 针 2.54 毫米 PCB 通用螺丝接线端子 eBay

1 个齐纳二极管 3.6V; 0.5W 1N4732A 易趣

电线

电源:对于 OO/HO 布局,使用 14v 直流电源(例如来自 eBay 的笔记本电脑充电器)。例如,这可提供高达 2.5 安培的电流。检查面板安装插座的尺寸,以适应为此项目选择的电源上的 DC 插头。 https://www.ebay.co.uk/itm/Samsung-AC-DC-Adapter-...

要扩展 HC-06 Bt 模块的范围,请将电线焊接到模块天线的末端。我使用了一根长 31.2 毫米的实心铜线(来自电源地线)(2.4 GHz 波长的 1/4)。见上图。请注意 - HC-06 连接是 Rx(在 PCB 上)到 Rx(在模块上)和 Tx 到 Tx。请注意,天线线应套上套管,以免与其他元件意外短路。

为了使用 LMD18200 h 桥模块(如上所示,这是带有散热器等的模块形式),我添加了电流检测组件,以防止火车轨道上出现短路或过载问题,更新后的电路图和 Arduino代码现在包括电流检测功能。

当达到时,代码将最大电流限制为 2 安培,LMD18200 h 桥通过将来自 Arduino 上的 D13 的高信号应用到 h 桥上的“制动”输入来关闭。

使用 0.1 ohm 电流检测电阻器可在 Arduino 传感器引脚 A0 上提供 0 到 200 mv 的模拟输入范围,以支持高达 2 Amps 的负载。对于每个模拟步进输入大约 5mv(1023 个总步进或分度)给出 0 到 40 个分度或 2 安培 / 40 =50mA 每分度。测得的电流精度为 50 mA,但是当达到 2 Amps 时,我们正在保护 h 桥。 LMD18200 还具有内置的过热保护功能作为后备。if(C>2000){ // 2 amps

Serial.println("过流");数字写入(13,高); }

当前绘制的值每秒通过蓝牙发送到Android App。void send_c(){t =millis() - lastmillis; if (t>=interval){ bluetooth.write(sensorValue);蓝牙.write('c'); lastmillis =毫秒(); } }

第 3 步:Android 应用

从 Google Play 商店下载免费应用程序 - 'LocoMotive'

从 Google Play 商店下载完整的应用程序(5.99 英镑) - 'LocoMotive DCC'

附上完整版应用程序的说明。

代码

  • locomotive_dcc_sep19.ino
locomotive_dcc_sep19.inoArduino
Arduino 代码
// 2019 年 9 月 1 日// 草图,用于使用 LMD18200 h 桥的 Android 应用“机车 DCC”// 添加了 CV 读/写工具#include SoftwareSerial bluetooth(8,9); // RX TXint C;int sensorValue;long t =0;long lastmillis =0;long interval =1000;String inString;int a[8];int preamable_type =0;int Address;float CV_VAL;float cv_val;float cv_val0; float cv_val1;float cv_val2;float cv_val3;float cv_val4;float cv_val5;float cv_val6;float cv_val7;int test_num;int cv_write_val;int Cs;boolean cv_logic;boolean ok;int num;// 使用数字引脚 6 和 5 进行 DCC 输出//定时器频率为 2MHz for ( /8 prescale from 16MHz )#define TIMER_SHORT 0x8D // 58usec 脉冲长度 #define TIMER_LONG 0x1B // 116usec 脉冲长度 unsigned char last_timer=TIMER_SHORT; // 存储最后一个定时器值 unsigned char flag=0; // 用于短脉冲或长脉冲无符号字符 every_second_isr =0; // 脉冲向上或向下// 状态机的定义 #define PREAMBLE 0 #define SEPERATOR 1#define SENDBYTE 2unsigned char state=PREAMBLE;unsigned char preamble_count =16;unsigned char outbyte =0;unsigned char cbit =0x80;// variables unsigned char xdata =0, data =0, data_f =0,data_f1 =0,data_f2 =0;int locoAdr =9; // 这是命令结构消息的 loco// 缓冲区的默认地址 Message { unsigned char data[7]; unsigned char len;};#define MAXMSG 3// 暂时只使用 2 条消息 - idle msg, the loco Speed msg, function msgstruct Message msg[MAXMSG] ={ { { 0xFF,0, 0xFF, 0, 0, 0, 0}, 3}, // idle msg { { locoAdr, 0, 0, 0, 0, 0, 0}, 3} // locoMsg 128个速度步 0x3f }; // loco msg 后面必须填入速度和异或数据字节 int msgIndex=0; int byteIndex=0;//Setup Timer2.//配置8位Timer2以指定频率产生中断。//返回时间加载值,该值必须加载到ISR例程中的TCNT2中。void SetupTimer2(){ //Timer2 Settings:Timer Prescaler /8, mode 0 //Timmer clock =16MHz/8 =2MHz oder 0,5usec TCCR2A =0; TCCR2B =0<=MAXMSG) { msgIndex =0; } 字节索引 =0; // 从字节 0 开始 msg } break;案例分隔符:标志=0; // 长脉冲 // 然后前进到下一个状态 state =SENDBYTE; // 转到下一个字节 ... cbit =0x80; // 下次先发送这个位 outbyte =msg[msgIndex].data[byteIndex];休息; case SENDBYTE:if (outbyte &cbit) { flag =1; // 发送短脉冲 } else { flag =0; // 发送长脉冲 } cbit =cbit>> 1; if (cbit ==0) { // 发送最后一位,是否有下一个字节?字节索引++; if (byteIndex>=msg[msgIndex].len) { // 这已经是 XOR 字节然后前进到前导状态 =PREAMBLE;如果(preamable_type ==0){ preamble_count =16; // 16 '1's 的正常前导码长度 } if (preamable_type ==1){ preamble_count =24; // 用于 CV1 写入的 24 个 1 的前导码 } } else { // 发送分隔符并前进到下一个字节 state =SEPERATOR; } } 休息; } if (flag) { // 如果数据==1 那么短脉冲延迟=TCNT2; TCNT2=延迟+TIMER_SHORT; last_timer=TIMER_SHORT; } else { // 长脉冲延迟=TCNT2; TCNT2=延迟+TIMER_LONG; last_timer=TIMER_LONG; } }}void setup(){Serial.begin(115200);analogReference(INTERNAL);pinMode(13, OUTPUT);蓝牙。开始(9600);延迟(500); // 等待蓝牙模块启动 Serial.println("Bluetooth Started"); bluetooth.println("蓝牙启动");DDRD =B01100000; // 为数字引脚 5 注册 D5,为数字引脚 6 注册 D6 //启动定时器 SetupTimer2();t =millis();lastmillis =millis();digitalWrite(6, LOW);digitalWrite(13, HIGH); // 转桥 o/p offint get_cv_val =cv_calc(test_num);}void current(){int i;整数值 =0; int numReadings =5;for (i =0; i 2000){ // 2 amps Serial.println("Over Current"); bluetooth.println("短!");数字写入(6,低); // DCC 信号的逻辑控制为低(关) digitalWrite(13, HIGH); // 刹车,短路 h-bridge o/p bluetooth.println(C); }}void loop() { if(bluetooth.available() ==true); { inString =bluetooth.readStringUntil('\n'); Serial.println(inString); } if (inString.substring(0,1) =="D"){ string(); } // 传入的 DCC 数据包 if (inString.substring(0,1) =="C"){ digitalWrite(6, HIGH);数字写入(13,低); } // 过流后复位,DCC信号逻辑控制开启,刹车关闭 if (inString.substring(0,1) =="G"){ digitalWrite(6, HIGH);数字写入(13,低);当前的(); bluetooth.println(C);} // 请求加载当前值 if (inString.substring(0,1) =="A"){ digitalWrite(6, HIGH);数字写入(13,低); get_cv_data(); cv1_prog();数字写入(6,低); digitalWrite(13, HIGH);} if (inString.substring(0,3) =="get"){ cv_val =0;数字写入(6,高);数字写入(13,低); get_cv_num(); cv_read();数字写入(6,低);数字写入(13,高); } if (inString.substring(0,3) =="add"){ cv_write_val =0;数字写入(6,高);数字写入(13,低); get_cv_new_val(); repeat_cv_write();数字写入(6,低);数字写入(13,高); } if (inString.substring(0,1) =="V"){ delay(50);bluetooth.print("CV1 updated"); Serial.println(Address);} // cv1 write if (inString.substring(0,1) =="E"){ digitalWrite(6, LOW); // DCC 信号的逻辑控制为低(关) digitalWrite(13, HIGH); // 刹车,使 h-bridge o/p 短路 } // 急停 inString =""; }void get_cv_new_val(){ Serial.println(inString);字符串 cv_w =""; int x =inString.indexOf("new,") + 4; cv_w =inString.substring(x,x+3); Serial.println(cv_w); cv_write_val =cv_w.toInt(); Serial.print("cv_write_val:");Serial.println(cv_write_val);字符串地址=""; int z =inString.indexOf("addr,") + 5; addr =inString.substring(z,z+1); Serial.println(地址);地址 =addr.toInt(); Serial.print("地址:");Serial.println(地址); }void get_cv_num(){ cv_write_val =0; Serial.println(inString);字符串临时 =""; int x =inString.indexOf(",") + 1; temp =inString.substring(x,8); Serial.println(temp);地址 =temp.toInt(); Serial.print("地址:");Serial.println(地址); } void get_cv_data(){ unsigned long z =inString.length(); int y =0;整数计数 =0;字符串 inChar;字符串临时 =""; for (int i =0; i<=z; i++){ inChar =inString.substring(i,i+1); if (inChar ==",") {count++;} if (inChar !="," &&inChar !="A") {temp +=inChar;} if (inChar ==",") {Address =(temp .toInt());y =y +1;temp ="";} } amend_len3(msg[1]); assemble_3_byte(); Serial.println(inString); } void string(){ unsigned long z =inString.length(); int y =0; for (int i =0; i<=5; i++){ a[i] =0; }int 计数 =0; String inChar;String temp=""; for (int i =0; i<=z; i++){ inChar =inString.substring(i,i+1); if (inChar ==",") { count++; } if (inChar !="," &&inChar !="D") { temp +=inChar; } if (inChar ==",") { a[y] =(temp.toInt()); y =y +1;温度 =""; } } if (count ==3){ //Serial.println(inString); //print_data(); amend_len3(msg[1]); assemble_3_byte(); } if (count ==4){ //Serial.println(inString); //print_data(); amend_len4(msg[1]); assemble_4_byte(); } //Serial.println(inString); //Serial.println(a[1]); // Serial.println(a[2]); //Serial.println(a[3]); //Serial.println(a[4]); //print_data(); } void amend_len4 (struct Message &x) { x.len =4; //Serial.println(x.len);}void assemble_4_byte() { preamable_type =0; // 16 x '1's noInterrupts(); msg[0].data[0] =B11111111; msg[0].data[1] =B00000000; msg[0].data[2] =B11111111; msg[1].data[0] =a[1]; msg[1].data[1] =a[2]; msg[1].data[2] =a[3]; msg[1].data[3] =((a[1] ^ a[2])^ a[3]);中断();}void amend_len3 (struct Message &x) { x.len =3; //Serial.println(x.len);}void assemble_3_byte() { preamable_type =0; // 16 x '1's noInterrupts(); msg[0].data[0] =B11111111; msg[0].data[1] =B00000000; msg[0].data[2] =B11111111; msg[1].data[0] =a[1]; msg[1].data[1] =a[2]; msg[1].data[2] =(a[1] ^ a[2]);味精[1].数据[3] =0;中断(); }void print_data(){ Serial.print(msg[1].data[0], DEC); Serial.print(","); Serial.print(msg[1].data[1], DEC); Serial.print(","); Serial.print(msg[1].data[2], DEC); Serial.print(","); Serial.print(msg[1].data[3], DEC); Serial.println(","); }//CV readvoid cv_current(){for (int i =1; i<=10; i++){ sensorValue =analogRead(A0); C =10.8 * 传感器值; // mA if (C>=Cs){ cv_logic =true;延迟微秒(500); Serial.print("C =");Serial.println(C);}}void cv_read(){ cv_val =0;延迟(200);当前的(); if(bluetooth.available() ==true);{ bluetooth.print("reading.."); } Cs =C + 50; CV_VAL =99; for (int f =1; f<=10; f++){ if (CV_VAL ==99){ cv_val0 =cv_calc(0);延迟(10); } } CV_VAL =99; for (int f =1; f<=10; f++){ if (CV_VAL ==99){ cv_val1 =cv_calc(1);延迟(10); } } CV_VAL =99; for (int f =1; f<=10; f++){ if (CV_VAL ==99){ cv_val2 =cv_calc(2);延迟(10); } } CV_VAL =99; for (int f =1; f<=10; f++){ if (CV_VAL ==99){ cv_val3 =cv_calc(3);延迟(10); } } CV_VAL =99; for (int f =1; f<=10; f++){ if (CV_VAL ==99){ cv_val4 =cv_calc(4);延迟(10); } } CV_VAL =99; for (int f =1; f<=10; f++){ if (CV_VAL ==99){ cv_val5 =cv_calc(5);延迟(10); } } CV_VAL =99; for (int f =1; f<=10; f++){ if (CV_VAL ==99){ cv_val6 =cv_calc(6);延迟(10); } } CV_VAL =99; for (int f =1; f<=10; f++){ if (CV_VAL ==99){ cv_val7 =cv_calc(7);延迟(10); Serial.print("cv_val0");Serial.println(cv_val0); Serial.print("cv_val1");Serial.println(cv_val1); Serial.print("cv_val2");Serial.println(cv_val2); Serial.print("cv_val3");Serial.println(cv_val3); Serial.print("cv_val4");Serial.println(cv_val4); Serial.print("cv_val5");Serial.println(cv_val5); Serial.print("cv_val6");Serial.println(cv_val6); Serial.print("cv_val7");Serial.println(cv_val7); int cv_val_total =cv_val0+cv_val1+cv_val2+cv_val3+cv_val4+cv_val5+cv_val6+cv_val7; cv_val =0;如果(cv_val0 ==1){ cv_val =cv_val + 1; } if (cv_val1 ==1){ cv_val =cv_val + 2; } if (cv_val2 ==1){ cv_val =cv_val + 4; } if (cv_val3 ==1){ cv_val =cv_val + 8; } if (cv_val4 ==1){ cv_val =cv_val + 16; } if (cv_val5 ==1){ cv_val =cv_val + 32; } if (cv_val6 ==1){ cv_val =cv_val + 64; } if (cv_val7 ==1){ cv_val =cv_val + 128; } if(bluetooth.available() ==true);{ if (cv_val_total> 9){ bluetooth.print("read =error"); } if (cv_val_total <9){ bluetooth.print("read ="); bluetooth.println(int(cv_val + 0.5)); } }Serial.print("cv_val ");Serial.println(int(cv_val + 0.5));}void cv1_prog(){for (int i =0; i<=3; i++){ reset_packet();延迟(5); }for (int i =0; i<=5; i++){ page_preset_packet();延迟(5); }for (int i =0; i<=9; i++){ reset_packet();延迟(5); } for (int i =0; i<=5; i++){ cv1_write_packet();延迟(5); } current(); for (int i =0; i<=10; i++){ cv1_write_packet();延迟(5); } }void reset_packet() { noInterrupts(); preamable_type =0; msg[0].data[0] =B11111111; msg[0].data[1] =B11111111; msg[0].data[2] =B11111111; msg[1].data[0] =B00000000; msg[1].data[1] =B00000000; msg[1].data[2] =B00000000;中断();}void page_preset_packet(){ noInterrupts(); preamable_type =0; // 16 x '1's msg[0].data[0] =B11111111; msg[0].data[1] =B11111111; msg[0].data[2] =B11111111; msg[1].data[0] =B01111101; msg[1].data[1] =B00000001; msg[1].data[2] =B01111100;中断();}void cv1_write_packet(){ preamable_type =1; // 24 x '1's noInterrupts(); msg[0].data[0] =B11111111; msg[0].data[1] =B11111111; msg[0].data[2] =B11111111; msg[1].data[0] =B01111000; // 仅地址模式 msg[1].data[1] =B00000000 |地址; msg[1].data[2] =(msg[1].data[0] ^ msg[1].data[1]);中断();}void cv_verify1_packet(){ noInterrupts(); preamable_type =1; // 24 x '1's msg[0].data[0] =B11111111; msg[0].data[1] =B11111111; msg[0].data[2] =B11111111; msg[1].data[0] =B01111000; // 位操作模式 msg[1].data[1] =B00000000 | (地址1); msg[1].data[2] =B11101000 |数量; msg[1].data[3] =(msg[1].data[0] ^ msg[1].data[1]) ^ msg[1].data[2];中断(); }void cv_verify0_packet() { noInterrupts(); preamable_type =1; // 24 x '1's msg[0].data[0] =B11111111; msg[0].data[1] =B11111111; msg[0].data[2] =B11111111; msg[1].data[0] =B01111000; // 位操作模式 msg[1].data[1] =B00000000 | (地址1); msg[1].data[2] =B11100000 |数量; msg[1].data[3] =(msg[1].data[0] ^ msg[1].data[1]) ^ msg[1].data[2];中断(); }void cv_write_packet() { preamable_type =1; // 24 x '1's noInterrupts(); msg[0].data[0] =B11111111; msg[0].data[1] =B11111111; msg[0].data[2] =B11111111; msg[1].data[0] =B01111100; // 写模式 msg[1].data[1] =B00000000 | (地址1); msg[1].data[2] =B00000000 | cv_write_val; msg[1].data[3] =(msg[1].data[0] ^ msg[1].data[1]) ^ msg[1].data[2];中断(); }void valid_packet(){ noInterrupts(); msg[0].data[0] =B11111111; msg[0].data[1] =B00000000; msg[0].data[2] =B11111111; preamable_type =0; // 16 x '1's msg[1].data[0] =(地址 - 1); msg[1].data[1] =0x80; // locoMsg 与第一组指令 0x80 msg[1].data[2] =msg[1].data[0] ^ msg[1].data[1];味精[1].数据[3] =0; interrupts();}//CV writevoid repeat_cv_write() { current(); Cs =C + 50; Serial.print("C =");Serial.println(C); Serial.print("Cs =");Serial.println(Cs); if(bluetooth.available() ==true);{ bluetooth.print("writing..");好 =假; for (int f =1; f<=10; f++){ if (ok ==false){ cv_write();延迟(10); } } }void cv_write(){ 延迟(100); amend_len3(msg[1]); assemble_3_byte();延迟(5);对于(int i =1;i<=20;i++){valid_packet();延迟(5); } for (int i =1; i<=6; i++){ reset_packet();延迟(5); cv_logic =假; amend_len4(msg[1]); assemble_4_byte();for (int i =1; i<=10; i++){ cv_write_packet(); cv_current(); Serial.print("C=");Serial.println(C);如果(cv_logic){ ok =true; cv_logic =假;我 =11; amend_len3(msg[1]); assemble_3_byte(); for (int i =1; i<=10; i++){ reset_packet();延迟(5); } if(bluetooth.available() ==true);{ bluetooth.print("write ="); bluetooth.println(cv_write_val); Serial.print("cv_write_val");Serial.println(cv_write_val); } } } if(bluetooth.available() ==true);{ if (ok ==false){ bluetooth.print("write =error"); } }}int cv_calc(int test_num) { amend_len3(msg[1]); assemble_3_byte();延迟(5);对于(int i =1;i<=20;i++){valid_packet();延迟(5); } num =test_num; amend_len3(msg[1]); assemble_3_byte(); for (int k =1; k<=4; k++){ reset_packet();延迟(5); } amend_len4(msg[1]); assemble_4_byte(); cv_logic =假;延迟(2); for (int m =1; m<=5; m++){ cv_verify1_packet(); cv_current();如果(cv_logic){cv_logic =false; CV_VAL =1; Serial.print("test_num =");Serial.println(test_num); Serial.println(CV_VAL); preamable_type =0; amend_len3(msg[1]); assemble_3_byte();延迟(5); for (int j =1; j<=3; j++){ reset_packet();延迟(5); }}}Serial.println("测试为0"); amend_len3(msg[1]); assemble_3_byte(); for (int k =1; k<=4; k++){ reset_packet();延迟(5); } amend_len4(msg[1]); assemble_4_byte(); cv_logic =假;延迟(2);对于(int m =1;m<=5;m++){cv_verify0_packet(); cv_current();如果(cv_logic){cv_logic =false; CV_VAL =0; Serial.print("test_num =");Serial.println(test_num); Serial.println(CV_VAL); preamable_type =0; amend_len3(msg[1]); assemble_3_byte();延迟(5); for (int j =1; j<=3; j++){ reset_packet();延迟(5); }}}Serial.println(CV_VAL);返回CV_VAL; }

定制零件和外壳

外壳内的完整电路

示意图

蓝牙接收器/H桥放大器电路 bluetooth_android_dcc_lmd18200_S8NTVsI4LY.fzzApp使用说明

制造工艺

  1. MrRobot – 支持 Ubuntu 移动应用的机器人(涉及 Raspberry Pi 和 arduino)
  2. 6-Shooter:Arduino 饮料混合站
  3. Arduino 数字骰子
  4. Arduino 游戏控制器
  5. LCD 动画和游戏
  6. 智能鞋(自动系带和发电)
  7. Sonar 使用 arduino 并在处理 IDE 上显示
  8. 像素追逐游戏
  9. 使用 Bolt 和 Arduino 控制 LED 亮度
  10. $10 便携式 Arduino 气象站 (AWS)
  11. Python3 和 Arduino 通信
  12. eDOT - 基于 Arduino 的精密时钟和气象站