0
  • 聊天消息
  • 系统消息
  • 评论与回复
登录后你可以
  • 下载海量资料
  • 学习在线课程
  • 观看技术视频
  • 写文章/发帖/加入社区
会员中心
创作中心

完善资料让更多小伙伴认识你,还能领取20积分哦,立即完善>

3天内不再提示

自己编写函数示例代码很难吗?分享几个示例!

得捷电子DigiKey 来源:未知 2023-11-16 16:05 次阅读
加入交流群
微信小助手二维码

扫码添加小助手

加入工程师交流群

Q A &

问:Arduino Uno的函数示例

我决定自己编写函数示例代码,因为这应该是Arduino中的基本示例。网络上确实有关于使用函数的文档,但是,如果要尝试使用代码环境,则必须得访问Arduino网站,而且他们的示例扩展的效果并不好。本帖将分成以下几个部分:以不包含任何函数的起始代码为例、使用一个函数转换相同的程序、展示可以利用函数做些什么的扩展示例、与没有函数的代码版本进行比较,表明更少的代码更易于使用。注意,本例假设已知一些基本的Arduino示例。

无函数的起始代码

/*

* This code is the starting code for my functionExample, I want to turn pins 13, 12, 11 high; wait for half a second; turn all the pins off; wait for half a second;

* and turn pins 13 and 11 on while keeping 12 off and wait for another half second.

*/

void setup() {

pinMode(13, OUTPUT);

pinMode(12, OUTPUT);

pinMode(11, OUTPUT);

}

boolean writePin = HIGH; //set a global variable to make it easier to turn things on and off in the function, use !writePin for LOW

void loop() {

//first, let's see how cumbersome writing code can be when trying to run several LEDs

//write all output pins high:

digitalWrite(13, writePin);

digitalWrite(12, writePin);

digitalWrite(11, writePin);

delay(500); //delay half a second

//write all pins low

digitalWrite(13, !writePin);

digitalWrite(12, !writePin);

digitalWrite(11, !writePin);

delay(500); //delay half a second

//write 13 and 11 high, keep 12 low

digitalWrite(13, writePin);

digitalWrite(12, !writePin);

digitalWrite(11, writePin);

delay(500);//delay half a second

//doing that sequence alone takes 12 lines of code to accomplish something that could probably be done in less

}

// 20 lines of code not including comments

向上滑动查看完整代码

我通常会计算包含{}的重要代码行的数量,而不计算注释,因为这些注释无论如何都会在编译器中被忽略。这篇代码看起来非常笨拙,包含很多重复的行,因此如果需要执行不同的操作,你就必须进行更改。在进行故障排除或开发更为复杂的程序时,其效率会非常低下。

利用函数重新改造起始代码

/*

TheArduino home page does

try toexplain funcitons using a math example and reading an analog pin, which iscool, but there are more things one can

do withfunctions. The anatomy of a function in Arduino is as follows:

dataTypevariableName(dataType parameterVariable1, dataType parameterVariable2, ...){}

Allfunctions have to have a valid Arduino dataType at the beginning of the line ofcode because we use a variable to reference the entire code that will be runbetween the {}

If youwant numbers or some sort of result with measurable values, you will have touse a data type that can store those values; examples are

int,double, unsigned long, long, boolean, float (and all the other types that canstore data)

The onlything to mention is that functions with these dataTypes must have a returnstatement; Example:

intaddTwoNumb(int one, int two){

intresult = one + two;

returnresult;

}

Thefunction above returns the calculation of one and two and can be stored in anew variable when called/used in the main loop.

Thevalues inside the () are called parameters, functions don't always requireparameters (most do though), so the () can be empty.

Parameters are placeholder variables with anydata type valid in Arduino. These variables do not have to be assigned valuesuntil the function is used/called in the main loop, values are passed as soonas they are called. Any number of new variables can be added into a functionand any amount of code can be added to a function, even functions can callother functions! (gets a little confusing at that point)

*/

void setup() {

pinMode(13, OUTPUT);

pinMode(12, OUTPUT);

pinMode(11, OUTPUT);

}

boolean writePin = HIGH; //set a globalvariable to make it easier to turn things on and off in the function, use!writePin for LOW

void loop() {

sequenceLights(13, 12, 11, writePin, writePin, writePin, 500);//call/use sequence lights on pins 13, 12, 11; use the default value forwritePin (HIGH), delay for half a second (500 mS)

sequenceLights(13, 12, 11, !writePin, !writePin, !writePin, 500);

sequenceLights(13, 12, 11, writePin, !writePin, writePin, 500);

}

/* Functions are typically defined or writtenbelow the loop statement for clarity*/

//notice that the function below uses the exactsame code but uses different variables and that we don't use a datatype (void),we aren't calculating anything, so there doesn't need to be a datatype

//the function takes 3 integers to begin with:pin13, pin12, pin11; these represent the values for the pins we want to control

//then the next three values are writeFunc1,writeFunc2, writeFunc3 which are boolean values used to control the pins (HIGHor LOW), we want to be able to use unique instructions per light as that is howthe original sequence worked

//finaly delayPeriod is used in place of 500,because what if we want to change the timing, why not?

void sequenceLights(int pin13, int pin12, intpin11, boolean writeFunc1, boolean writeFunc2, boolean writeFunc3, intdelayPeriod){

digitalWrite(pin13, writeFunc1);

digitalWrite(pin12, writeFunc2);

digitalWrite(pin11, writeFunc3);

delay(delayPeriod);

}

//17 lines of code not including comments

void setup() {

//Serial.begin(9600); //I often use the serial monitor to debug myprogram or to do some testing, I then comment the line of code to increase someruntime speed (counted this line of commented code as it was essential to myprocess)

pinMode(13, OUTPUT);

pinMode(12, OUTPUT);

pinMode(11, OUTPUT);

pinMode(10, OUTPUT);

pinMode(9, OUTPUT);

pinMode(8, OUTPUT);

}

int countRndSeq = 0; //set initial variable forcounting variable for the random sequence to "reset"

int randPin = random(8, 14); //set the randomPin variable to a random number between 8 and 13 (14 for including 13 as achoice); we only need 8-13 as those are the pins I use

void loop() {

randSequenceLightSlow(5, 125, 1200); //run function for a randomsequence, set counting interval at 5, set minimum delay at 125, set the maxdelay to 1200 (1.2 seconds) (I decided to move the randMode into the functionbecause it was easier to accomplish)

countRndSeq = 0; //reset the counter for the next sequence

delay(3000); //wait three seconds then turn off all the lights (made afunction for that)

allPinsWrite(13, 12, 11, 10, 9, 8 , LOW);

randSequenceLightSlow(7, 125, 1450); //run function for random sequenceusing counting interval at 7, minimum delay at 125, set max delay to 1450(1.450 seconds)

countRndSeq = 0; //reset counter for next sequence

delay(3000); //wait three seconds and turn off all the lights

allPinsWrite(13, 12, 11, 10, 9, 8, LOW);

}

/*

* Thefollowing uses a while loop for control, it does random lights and slows downdelay by a set interval between steps (larger interval will make it count andslow down much quicker)

* Aslong as that counting number (countRndSeq) is less than the max delay (maxDel),it will do the following in order:

* 1.chose a random pin 8-13 and set it equal to a variable

* 2.Pick the random Mode value each time the while loop runs again (increaseschance to get modes 0-2)

* 2.turn off the pin associated to that number using the delay amount of the samenumber that countrRndSeq is currently at

* 3.Increase countRndSeq by the interval amount set by calling the function (can beany integer)

* 4.Check if the current count is greater than the minimum delay and then checkwhich mode (remember I set it to random above); there are 3 modes 0, 1, 2

* NOTE:For #4, 0 has a high chance of adding less to countRndSeq, 1 has a mediumchance of adding a bit more to countRndSeq, 2 has a low chance of adding quitea bit to countRndSeq

* 5. Setthe final pin after the sequence has finished to high to simulate that is thefinal pin the program landed on

* SeecalcThreshChance for an explanation of how I made weighted random events forthe chance for the lights to slow faster

*/

void randSequenceLightSlow(int interval, intminDel, int maxDel){

while(countRndSeq < maxDel){

randPin = random(8, 14);

intmode = random(0, 3);

digitalWrite(randPin, HIGH);

delay(countRndSeq);

digitalWrite(randPin, LOW);

delay(countRndSeq);

countRndSeq += interval;

if(countRndSeq > minDel && mode == 0){

countRndSeq += calcThreshChance(mode, interval);

}else if(countRndSeq > minDel && mode == 1){

countRndSeq += calcThreshChance(mode, interval);

}else if(countRndSeq > minDel && mode == 2){

countRndSeq += calcThreshChance(mode, interval);

}

}

digitalWrite(randPin, HIGH);

}

/*

* Simplefunction that uses integers 8-13 and a boolean value to turn on or off all theLEDs at once

*/

void allPinsWrite(int p1, int p2, int p3, intp4, int p5, int p6, boolean writeInst){

digitalWrite(p1, writeInst);

digitalWrite(p2, writeInst);

digitalWrite(p3, writeInst);

digitalWrite(p4, writeInst);

digitalWrite(p5, writeInst);

digitalWrite(p6, writeInst);

}

/*

* Thefollowing function takes an integer 0-2 and calculates the chance for it to addmore to the number countRndSeq

* Firstit sets up three variables local to the function (chance for around 50, achance for around 200, and a chance for around 300)

* Thenthe following first check is made: check which mode is selected, 0, 1, or 2 (ifsomeone entered something else or not calculated it will return 0 and count bythe regular interval in the randomSequence)

* If itis mode 0, use a relatively short random range from 45 to 69 and check if thatrandom number falls between 50 and 60 which is a pretty high chance based onthe short range, so it will more than likely add 1000 plus that random numberto countRndSeq

* If itis mode 1, use a larger range from 200 to 299 and check if that random numberlies between 250 and 255, which is a medium chance, so it may or may not usethat random number + 2000

* If itis mode 2, use a much larger range from 300 to 599 and check if that randomnumber lies between 320 and 324, which is a low chance, so it has lesslikelihood of using that random number and adding 3000

* Allother cases it will just add the regular interval

*/

int calcThreshChance(int mode, int interval){

intrandCh50 = 0;

intrandCh200 = 0;

intrandCh300 = 0;

if(mode == 0){

randCh50 = random(45, 70);

if(randCh50 >= 50 && randCh50 <= 60){

return randCh50 + 1000;

}else {

return interval;

}

}else if (mode == 1){

randCh200 = random(200, 300);

if(randCh200 >= 250 && randCh200 <= 255){

return randCh200 + 2000;

}else {

return interval;

}

}else if (mode == 2){

randCh300 = random(300, 600);

if(randCh300 >= 320 && randCh300 <= 324){

return randCh300 + 3000;

}else {

return interval;

}

}else {

return interval;

}

}

//77 lines of code not including comments

向上滑动查看完整代码

即使整篇代码只减少了3行,但在希望试验延迟值或者引脚是变高还是变低等情况下,你就能轻松快速地调整相关值。如果没有函数,你每次都需要手动添加四行代码。

初始代码接线图

wKgaomVVzmuAepXUAAGhHEQTe5I163.png

使用函数的扩展代码

void setup() {

//Serial.begin(9600); //I often use the serial monitor to debug my program or to do some testing, I then comment the line of code to increase some runtime speed (counted this line of commented code as it was essential to my process)

pinMode(13, OUTPUT);

pinMode(12, OUTPUT);

pinMode(11, OUTPUT);

pinMode(10, OUTPUT);

pinMode(9, OUTPUT);

pinMode(8, OUTPUT);

}

int countRndSeq = 0; //set initial variable for counting variable for the random sequence to "reset"

int randPin = random(8, 14); //set the random Pin variable to a random number between 8 and 13 (14 for including 13 as a choice); we only need 8-13 as those are the pins I use

void loop() {

randSequenceLightSlow(5, 125, 1200); //run function for a random sequence, set counting interval at 5, set minimum delay at 125, set the max delay to 1200 (1.2 seconds) (I decided to move the randMode into the function because it was easier to accomplish)

countRndSeq = 0; //reset the counter for the next sequence

delay(3000); //wait three seconds then turn off all the lights (made a function for that)

allPinsWrite(13, 12, 11, 10, 9, 8 , LOW);

randSequenceLightSlow(7, 125, 1450); //run function for random sequence using counting interval at 7, minimum delay at 125, set max delay to 1450 (1.450 seconds)

countRndSeq = 0; //reset counter for next sequence

delay(3000); //wait three seconds and turn off all the lights

allPinsWrite(13, 12, 11, 10, 9, 8, LOW);

}

/*

* The following uses a while loop for control, it does random lights and slows down delay by a set interval between steps (larger interval will make it count and slow down much quicker)

* As long as that counting number (countRndSeq) is less than the max delay (maxDel), it will do the following in order:

* 1. chose a random pin 8-13 and set it equal to a variable

* 2. Pick the random Mode value each time the while loop runs again (increases chance to get modes 0-2)

* 2. turn off the pin associated to that number using the delay amount of the same number that countrRndSeq is currently at

* 3. Increase countRndSeq by the interval amount set by calling the function (can be any integer)

* 4. Check if the current count is greater than the minimum delay and then check which mode (remember I set it to random above); there are 3 modes 0, 1, 2

* NOTE: For #4, 0 has a high chance of adding less to countRndSeq, 1 has a medium chance of adding a bit more to countRndSeq, 2 has a low chance of adding quite a bit to countRndSeq

* 5. Set the final pin after the sequence has finished to high to simulate that is the final pin the program landed on

* See calcThreshChance for an explanation of how I made weighted random events for the chance for the lights to slow faster

*/

void randSequenceLightSlow(int interval, int minDel, int maxDel){

while(countRndSeq < maxDel){

randPin = random(8, 14);

int mode = random(0, 3);

digitalWrite(randPin, HIGH);

delay(countRndSeq);

digitalWrite(randPin, LOW);

delay(countRndSeq);

countRndSeq += interval;

if(countRndSeq > minDel && mode == 0){

countRndSeq += calcThreshChance(mode, interval);

} else if(countRndSeq > minDel && mode == 1){

countRndSeq += calcThreshChance(mode, interval);

} else if(countRndSeq > minDel && mode == 2){

countRndSeq += calcThreshChance(mode, interval);

}

}

digitalWrite(randPin, HIGH);

}

/*

* Simple function that uses integers 8-13 and a boolean value to turn on or off all the LEDs at once

*/

void allPinsWrite(int p1, int p2, int p3, int p4, int p5, int p6, boolean writeInst){

digitalWrite(p1, writeInst);

digitalWrite(p2, writeInst);

digitalWrite(p3, writeInst);

digitalWrite(p4, writeInst);

digitalWrite(p5, writeInst);

digitalWrite(p6, writeInst);

}

/*

* The following function takes an integer 0-2 and calculates the chance for it to add more to the number countRndSeq

* First it sets up three variables local to the function (chance for around 50, a chance for around 200, and a chance for around 300)

* Then the following first check is made: check which mode is selected, 0, 1, or 2 (if someone entered something else or not calculated it will return 0 and count by the regular interval in the randomSequence)

* If it is mode 0, use a relatively short random range from 45 to 69 and check if that random number falls between 50 and 60 which is a pretty high chance based on the short range, so it will more than likely add 1000 plus that random number to countRndSeq

* If it is mode 1, use a larger range from 200 to 299 and check if that random number lies between 250 and 255, which is a medium chance, so it may or may not use that random number + 2000

* If it is mode 2, use a much larger range from 300 to 599 and check if that random number lies between 320 and 324, which is a low chance, so it has less likelihood of using that random number and adding 3000

* All other cases it will just add the regular interval

*/

int calcThreshChance(int mode, int interval){

int randCh50 = 0;

int randCh200 = 0;

int randCh300 = 0;

if(mode == 0){

randCh50 = random(45, 70);

if(randCh50 >= 50 && randCh50 <= 60){

return randCh50 + 1000;

} else {

return interval;

}

} else if (mode == 1){

randCh200 = random(200, 300);

if(randCh200 >= 250 && randCh200 <= 255){

return randCh200 + 2000;

} else {

return interval;

}

} else if (mode == 2){

randCh300 = random(300, 600);

if(randCh300 >= 320 && randCh300 <= 324){

return randCh300 + 3000;

} else {

return interval;

}

} else {

return interval;

}

}

//77 lines of code not including comments

向上滑动查看完整代码

这篇代码的主题是在一定程度上模拟六面骰子的滚动,该骰子起先快速滚动,后来逐渐减慢到静止不动。该代码包含内置随机函数,该函数使用了起始编号(包含在生成中)和在生成中排除的结束编号。它不仅随机化了引脚(8-13),还随机化了和一些骰子一样明显减速的几率。我用了三种几率“模式”来实现这一效果:高几率:计数变量的增量较少;中等几率:计数变量的增量稍多;低几率:计数变量的增量较多(请参见代码中的注释,了解完整的代码环境)。我创建了三个自定义函数,使这个概念更加易于理解和试验。

无自定义函数的扩展代码

void setup() {

pinMode(13, OUTPUT);

pinMode(12, OUTPUT);

pinMode(11, OUTPUT);

pinMode(10, OUTPUT);

pinMode(9, OUTPUT);

pinMode(8, OUTPUT);

}

int countRndSeq = 0;

int randPin = random(8,14);

int minDel1 = 125;

int maxDel1 = 1200;

int interval1 = 5;

int minDel2 = 125;

int maxDel2 = 1450;

int interval2 = 7;

int randCh50 = 0;

int randCh200 = 0;

int randCh300 = 0;

void loop() {

while(countRndSeq < maxDel1){

randPin = random(8, 14);

int randMode = random(0, 3);

digitalWrite(randPin, HIGH);

delay(countRndSeq);

digitalWrite(randPin, LOW);

delay(countRndSeq);

countRndSeq += interval1;

if(countRndSeq > minDel1 &&randMode == 0){

randCh50 = random(45, 70);

if(randCh50 >= 50 && randCh50<= 60){

countRndSeq += randCh50 + 1000;

} else {

countRndSeq += interval1;

}

} else if(countRndSeq > minDel1&& randMode == 1){

randCh200 = random(200, 300);

if(randCh200 >= 250 &&randCh200 <= 255){

countRndSeq += randCh200 + 2000;

} else {

countRndSeq += interval1;

}

} else if(countRndSeq > minDel1&& randMode == 2){

randCh200 = random(300, 600);

if(randCh200 >= 320 &&randCh200 <= 324){

countRndSeq += randCh200 + 3000;

} else {

countRndSeq += interval1;

}

} else {

countRndSeq += interval1;

}

}

digitalWrite(randPin, HIGH);

countRndSeq = 0;

delay(3000);

digitalWrite(13, LOW);

digitalWrite(12, LOW);

digitalWrite(11, LOW);

digitalWrite(10, LOW);

digitalWrite(9, LOW);

digitalWrite(8, LOW);

while(countRndSeq < maxDel2){

randPin = random(8, 14);

int randMode = random(0, 3);

digitalWrite(randPin, HIGH);

delay(countRndSeq);

digitalWrite(randPin, LOW);

delay(countRndSeq);

countRndSeq += interval2;

if(countRndSeq > minDel2 &&randMode == 0){

randCh50 = random(45, 70);

if(randCh50 >= 50 && randCh50<= 60){

countRndSeq += randCh50 + 1000;

} else {

countRndSeq += interval2;

}

} else if(countRndSeq > minDel2&& randMode == 1){

randCh200 = random(200, 300);

if(randCh200 >= 250 &&randCh200 <= 255){

countRndSeq += randCh200 + 2000;

} else {

countRndSeq += interval2;

}

} else if(countRndSeq > minDel2&& randMode == 2){

randCh200 = random(300, 600);

if(randCh200 >= 320 &&randCh200 <= 324){

countRndSeq += randCh200 + 3000;

} else {

countRndSeq += interval2;

}

} else {

countRndSeq += interval2;

}

}

digitalWrite(randPin, HIGH);

countRndSeq = 0;

delay(3000);

digitalWrite(13, LOW);

digitalWrite(12, LOW);

digitalWrite(11, LOW);

digitalWrite(10, LOW);

digitalWrite(9, LOW);

digitalWrite(8, LOW);

}

//105 lines of code not includingcomments

向上滑动查看完整代码

注意,在实现相同效果的情况下,此部分的代码数量显著增加(函数版本的代码少了28行,这在构建更大的程序时非常重要)。它不仅减少了代码数量,而且这些函数的使用方式非常便于利用不同的值进行试验。而手动编码版本的代码需要在代码中更改若干变量才能进行试验。想象一下,在需要进行大量试验的情况下,如果进行每个操作都需要更改代码,那将是多么的恐怖:而如果使用函数,那么只需编辑一个代码块即可快速测试功能。

扩展代码接线图

wKgaomVVzmuAB3R6AAIhJHrkI78378.png

wKgaomVVzmuAJKTQAAABcngP-W4683.png

更多Arduino技术相关内容请查看以下内容:
  • 适合Arduino 和 Raspberry Pi 匹配的摄像头

  • Arduino 睡眠模式示例

  • 如何选择适用于Arduino的IR、UV和可见光放射体

  • Arduino 扩展板

  • Arduino setup() 和 loop() 函数的目的是什么?
wKgaomVVzmuAJKTQAAABcngP-W4683.png    最后,如果你喜欢这篇文章,快分享给更多的小伙伴吧!切记点个赞哦!

提示点击菜单设计支持:工程师锦囊,获取更多工程师小贴士

秘技知识学不停 专属福利享不停

就等您加入!

点此登记

赚积分、换好礼

立即到「会员权益」查看您的礼遇! 如有任何问题,欢迎联系得捷电子DigiKey的客服团队

中国(人民币)客服

wKgaomVVzmyACSUiAAADBaTNctA728.png400-920-1199wKgaomVVzmyAZsabAAADAQryhLs299.png服务支持 > 联系客服 > 微信客服wKgaomVVzmyAQBCeAAADNUSMvSY160.pngservice.sh@digikey.comwKgaomVVzmyAWhZrAAACyRJDcPk809.png QQ在线实时咨询:4009201199

中国(美金)/ 香港客服

wKgaomVVzmyACSUiAAADBaTNctA728.png

400-882-4440

wKgaomVVzmyACSUiAAADBaTNctA728.png852-3104-0500wKgaomVVzmyAQBCeAAADNUSMvSY160.pngchina.support@digikey.comwKgaomVVzmyAa3huAACA1g3d7HM565.png

wKgaomVVzmyAOWUqAAJQEo9UZ9g372.png

点击下方“阅读原文”查看更多

让我知道你在看wKgaomVVzm2AbQQmAAAD385SHbk520.png


原文标题:自己编写函数示例代码很难吗?分享几个示例!

文章出处:【微信公众号:得捷电子DigiKey】欢迎添加关注!文章转载请注明出处。


声明:本文内容及配图由入驻作者撰写或者入驻合作网站授权转载。文章观点仅代表作者本人,不代表电子发烧友网立场。文章及其配图仅供工程师学习之用,如有内容侵权或者其他违规问题,请联系本站处理。 举报投诉
  • 得捷电子
    +关注

    关注

    1

    文章

    255

    浏览量

    13467

原文标题:自己编写函数示例代码很难吗?分享几个示例!

文章出处:【微信号:得捷电子DigiKey,微信公众号:得捷电子DigiKey】欢迎添加关注!文章转载请注明出处。

收藏 人收藏
加入交流群
微信小助手二维码

扫码添加小助手

加入工程师交流群

    评论

    相关推荐
    热点推荐

    Video Processing Subsystem与HDMI示例设计

    在撰写本文时,HDMI Transmitter Subsystem IP 核与 Video Processing Subsystem IP 核均有多个示例设计可供使用,但并没有演示将两者功能结合在一起来使用的设计。
    的头像 发表于 11-07 10:35 308次阅读
    Video Processing Subsystem与HDMI<b class='flag-5'>示例</b>设计

    淘宝京东API商品详情接口示例参考

    。 is_promotion:是否获取促销价,可选参数,根据需求设置。 其他参数可能包括返回字段列表、API密钥等,具体以API文档为准。 请求示例:   http复制代码GET https://eco.taobao.com
    的头像 发表于 11-04 09:36 132次阅读

    淘宝拍立淘接口实战:图像优化、识别调优与避坑代码示例

    本文详解淘宝拍立淘接口(taobao.picture.search)实战技巧,涵盖图像预处理、识别优化、签名生成与供应链数据联动,结合代码示例解析高频坑点,如Base64格式错误、限流处理、分页失效等,助开发者提升识别率至85%以上,高效对接电商选品与供应链系统。
    的头像 发表于 10-09 14:28 244次阅读

    请问如何构建 emWin 示例代码

    如何构建 emWin 示例代码
    发表于 09-04 07:25

    请问NuMicro® Cortex-M0/M4系列可以提供哪些USB器件示例代码

    NuMicro® Cortex-M0/M4系列可以提供哪些USB器件示例代码
    发表于 08-19 07:05

    BLE代码示例中Wi-Fi连接重试失败的原因?

    您好,我正在使用 BLE 代码示例进行 Wi-Fi 接入。我从 modus 工具箱下载了代码示例代码
    发表于 07-08 07:42

    用VSCode编写自己的KiCad插件(上)详细步骤教程

    “  很多小伙伴都想自己开发 KiCad 插件,但不知从何入手。本文由华秋电子的另一位 KiCad 开发者波波同学撰写,分享了如何快速搭建环境,并开发一个简单的插件。  ” 目标     编写一个
    的头像 发表于 06-17 11:10 2728次阅读
    用VSCode<b class='flag-5'>编写</b><b class='flag-5'>自己</b>的KiCad插件(上)详细步骤教程

    如何使用自定义设置回调函数

    你好,我正在尝试编写自己的自定义设置回调函数,并使用 fastEnum=false。 是否有任何代码示例或资料可供我参考? void CyU
    发表于 05-21 06:11

    如何获取用于开发fx2的sdk和示例代码

    大家好 我正在使用 FX2 设备,以前也使用过 FX3 设备。 使用 FX3 设备 SDK,当我下载它时,我在安装文件夹中获得了许多示例代码,但是它没有 FX2 的示例代码,我如何
    发表于 05-07 07:25

    (开源代码版)手把手教学:DVP摄像头拍照&amp;上传功能示例

    通过本开源示例即可完成DVP摄像头的拍照、图像预处理及云端上传全流程。示例代码包含完整工程、硬件配置说明及调试技巧,从环境搭建到功能实现,一步步带你构建稳定可靠的图像数据采集与传输系统,适用于智能
    的头像 发表于 04-21 15:23 807次阅读
    (开源<b class='flag-5'>代码</b>版)手把手教学:DVP摄像头拍照&amp;上传功能<b class='flag-5'>示例</b> !

    RAKsmart企业服务器上部署DeepSeek编写运行代码

    在RAKsmart企业服务器上部署并运行DeepSeek模型的代码示例和详细步骤。假设使用 Python + Transformers库 + FastAPI实现一个基础的AI服务。主机推荐小编为您整理发布RAKsmart企业服务器上部署DeepSeek
    的头像 发表于 03-25 10:39 542次阅读

    如何获取SMBus示例代码

    想找一个用硬件SMBus外设的示例代码,但是在网上找到的很多都是HAL库的版本,我目前的代码是用的标准库,想知道ST官方有没有相关的示例代码
    发表于 03-10 07:16

    用于 SPI 绝对编码器的 Arduino 示例代码

    作者:Damon Tarry, Design Applications Engineer, Same Sky 本 Arduino 示例代码教程旨在为用户提供一个坚实的起点,以便通过串行外设接口
    的头像 发表于 01-26 21:35 1304次阅读
    用于 SPI 绝对编码器的 Arduino <b class='flag-5'>示例</b><b class='flag-5'>代码</b>

    tcpdump使用示例

    这里收集了一些实用的 tcpdump 使用示例,使用它们可提升您的网络故障排除和安全测试能力。 熟练掌握下面的 tcpdump 使用示例,可以帮助我们更好的了解自己的网络。 了解 tcpdump
    的头像 发表于 01-06 09:33 1238次阅读

    基站/Wi-Fi/GPS定位相关示例来咯~记得收藏!!

    在现代科技飞速发展的今天,定位技术已成为我们生活中不可或缺的一部分。 今天特别分享定位相关示例。   一、基站/Wi-Fi/GPS定位示例 本文将通过基站/Wi-Fi/GPS定位具体应用示例
    的头像 发表于 12-18 16:42 1809次阅读
    基站/Wi-Fi/GPS定位相关<b class='flag-5'>示例</b>来咯~记得收藏!!