arduino环境搭建

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

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());
    }
    
上一篇:你管这叫代理模式(Proxy Pattern)


下一篇:恒流LED驱动芯片 SM15133EK SM15133EH 明微电子