ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

arduino环境搭建

2021-12-19 14:31:05  阅读:197  来源: 互联网

标签:LED pin arduino 环境 nulllab serial Serial 搭建


一、网上找到最便宜的板子

https://item.taobao.com/item.htm?spm=a1z09.2.0.0.2c802e8dP0EmQg&id=648413912304&_u=i1sscgpi56c8
13.8包邮

二、获取资料

  1. 可以选择TB详情页上给的库,也可以拿nulllab的库
    地址:
    https://gitee.com/nulllab/nulllab_arduino

三、开搞

  1. 在附加开发板管理器网址输入如下网址
    https://cdn.jsdelivr.net/gh/nulllaborg/arduino_nulllab/package_nulllab_boards_index_zh.json
  2. 开发板选DLY BOARD
  3. 配置如下:
    注意点:
    时钟必须是16M,否则定时都不准
    必须采用内部32M
    EEPROM必须选择 有 ,大小随意,不然会编译报错
    上传波特率不能是115200,可能这颗USB转TTL不太行
Clock Source:Internal 32M
Frequency: 16M
Variant:LGT328P-LQFP32
EEPROM SIZE:2KB  
Upload Speed:57600


四、简单例子

  1. LED闪烁,具体引脚可以看C:\Users\321\AppData\Local\Arduino15\packages\nulllab avr compatible boards\hardware\avr\2.0.0\variants\standard\pins_arduino.h

    #define LED_BUILTIN 	(13)
    

    INO

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

    /*
      Software serial multple serial test
     
     Receives from the hardware serial, sends to software serial.
     Receives from software serial, sends to hardware serial.
     
     The circuit: 
     * RX is digital pin 10 (connect to TX of other device)
     * TX is digital pin 11 (connect to RX of other device)
     
     Note:
     Not all pins on the Mega and Mega 2560 support change interrupts, 
     so only the following can be used for RX: 
     10, 11, 12, 13, 50, 51, 52, 53, 62, 63, 64, 65, 66, 67, 68, 69
     
     Not all pins on the Leonardo support change interrupts, 
     so only the following can be used for RX: 
     8, 9, 10, 11, 14 (MISO), 15 (SCK), 16 (MOSI).
     
     created back in the mists of time
     modified 25 May 2012
     by Tom Igoe
     based on Mikal Hart's example
     
     This example code is in the public domain.
     
     */
    #include <SoftwareSerial.h>
    
    SoftwareSerial mySerial(10, 11); // RX, TX
    
    void setup()  
    {
      // Open serial communications and wait for port to open:
      Serial.begin(57600);
      while (!Serial) {
        ; // wait for serial port to connect. Needed for Leonardo only
      }
    
    
      Serial.println("Goodnight moon!");
    
      // set the data rate for the SoftwareSerial port
      mySerial.begin(57600);
      mySerial.println("Hello, world?");
    }
    
    void loop() // run over and over
    {
      if (mySerial.available())
        Serial.write(mySerial.read());
      if (Serial.available())
        mySerial.write(Serial.read());
    }
    

标签:LED,pin,arduino,环境,nulllab,serial,Serial,搭建
来源: https://blog.csdn.net/xuan530482366/article/details/122018300

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有