402|0

58

帖子

0

TA的资源

一粒金砂(中级)

楼主
 

【Follow me第二季第2期】入门任务 [复制链接]

 

开箱

十分感谢得捷电子对本次活动的赞助,开发板的开箱照片

1_开箱照片
2_开箱照片
3_开箱照片
4_开箱照片

去官网下载Arduino IDE

5_Arduino官网
下载以后打开软件,需要下载Arduino UNO R4 WiFi对应的库文件,在设置和左边的菜单都中都可以选择

6_Arduino选择库文件
插上Arduino UNO R4 WiFi开发板,就直接识别到了
7_Arduino识别

任务一:搭建环境并开启第一步Blink / 串口打印Hello EEWorld!

8_Blink官方例程

这个是让开发板上LED自动闪烁的例程,直接在示例->basic->Blink中可以找到
官方写了详细的注释,甚至上放还提供了网址可以访问学习

  1. /*
  2. Blink
  3. Turns an LED on for one second, then off for one second, repeatedly.
  4. Most Arduinos have an on-board LED you can control. On the UNO, MEGA and ZERO
  5. it is attached to digital pin 13, on MKR1000 on pin 6. LED_BUILTIN is set to
  6. the correct LED pin independent of which board is used.
  7. If you want to know what pin the on-board LED is connected to on your Arduino
  8. model, check the Technical Specs of your board at:
  9. https://www.arduino.cc/en/Main/Products
  10. modified 8 May 2014
  11. by Scott Fitzgerald
  12. modified 2 Sep 2016
  13. by Arturo Guadalupi
  14. modified 8 Sep 2016
  15. by Colby Newman
  16. This example code is in the public domain.
  17. https://www.arduino.cc/en/Tutorial/BuiltInExamples/Blink
  18. */
  19. // the setup function runs once when you press reset or power the board
  20. void setup() {
  21. // initialize digital pin LED_BUILTIN as an output.
  22. pinMode(LED_BUILTIN, OUTPUT);
  23. }
  24. // the loop function runs over and over again forever
  25. void loop() {
  26. digitalWrite(LED_BUILTIN, HIGH);// turn the LED on (HIGH is the voltage level)
  27. delay(1000); // wait for a second
  28. digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW
  29. delay(1000); // wait for a second
  30. }

编译代码,烧录到开发板,LED灯可以闪烁

9_烧录成功

2)串口打印Hello EEWorld!

10_串口官方例程
官方提供了例程,直接在示例->Communication->SerialCallResponseASCII中可以找到
官方的例程是打印0,0,0,修改了Hello EEWorld!烧录,可以在串口助手中看到输出

  1. /*
  2. Serial Call and Response in ASCII
  3. Language: Wiring/Arduino
  4. This program sends an ASCII A (byte of value 65) on startup and repeats that
  5. until it gets some data in. Then it waits for a byte in the serial port, and
  6. sends three ASCII-encoded, comma-separated sensor values, truncated by a
  7. linefeed and carriage return, whenever it gets a byte in.
  8. The circuit:
  9. - potentiometers attached to analog inputs 0 and 1
  10. - pushbutton attached to digital I/O 2
  11. created 26 Sep 2005
  12. by Tom Igoe
  13. modified 24 Apr 2012
  14. by Tom Igoe and Scott Fitzgerald
  15. Thanks to Greg Shakar and Scott Fitzgerald for the improvements
  16. This example code is in the public domain.
  17. https://www.arduino.cc/en/Tutorial/BuiltInExamples/SerialCallResponseASCII
  18. */
  19. int firstSensor = 0; // first analog sensor
  20. int secondSensor = 0;// second analog sensor
  21. int thirdSensor = 0; // digital sensor
  22. int inByte = 0; // incoming serial byte
  23. void setup() {
  24. // start serial port at 9600 bps and wait for port to open:
  25. Serial.begin(9600);
  26. while (!Serial) {
  27. ;// wait for serial port to connect. Needed for native USB port only
  28. }
  29. pinMode(2, INPUT); // digital sensor is on digital pin 2
  30. establishContact();// send a byte to establish contact until receiver responds
  31. }
  32. void loop() {
  33. // if we get a valid byte, read analog ins:
  34. if (Serial.available() > 0) {
  35. // get incoming byte:
  36. inByte = Serial.read();
  37. // read first analog input:
  38. firstSensor = analogRead(A0);
  39. // read second analog input:
  40. secondSensor = analogRead(A1);
  41. // read switch, map it to 0 or 255
  42. thirdSensor = map(digitalRead(2), 0, 1, 0, 255);
  43. // send sensor values:
  44. Serial.print(firstSensor);
  45. Serial.print(",");
  46. Serial.print(secondSensor);
  47. Serial.print(",");
  48. Serial.println(thirdSensor);
  49. }
  50. }
  51. void establishContact() {
  52. while (Serial.available() <= 0) {
  53. Serial.println("Hello EEWorld!");// send an initial string
  54. delay(500);
  55. }
  56. }

11_串口助手输出
11_串口助手输出

参考资料

Arduino - Home
Arduino Documentation

点赞 关注
 
 

回复
举报
您需要登录后才可以回帖 登录 | 注册

随便看看
查找数据手册?

EEWorld Datasheet 技术支持

相关文章 更多>>
关闭
站长推荐上一条 1/10 下一条
有奖直播报名| TI 面向楼宇和工厂自动化行业的毫米波雷达解决方案
【内容简介】TI 60GHz IWRL6432和 IWRL1432毫米波雷达传感器如何帮助解决楼宇和工厂自动化应用中的感应难题
【直播时间】5月28日(周三)上午10:00
【直播礼品】小米双肩包、contigo水杯、胶囊伞、安克充电器

查看 »

 
EEWorld订阅号

 
EEWorld服务号

 
汽车开发圈

 
机器人开发圈

About Us 关于我们 客户服务 联系方式 器件索引 网站地图 最新更新 手机版

站点相关: 国产芯 安防电子 汽车电子 手机便携 工业控制 家用电子 医疗电子 测试测量 网络通信 物联网 9

北京市海淀区中关村大街18号B座15层1530室 电话:(010)82350740 邮编:100190

电子工程世界版权所有 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号 Copyright © 2005-2025 EEWORLD.com.cn, Inc. All rights reserved
快速回复 返回顶部 返回列表