First week study

Introduction to Arduino Basics

arduino is a convenient, flexible and easy to use open source electronic prototype platform, including hardware (various models of arduino boards) and software (arduino boards)   IDE).

Arduino can sense the environment through a variety of sensors and feed back and affect the environment by controlling lights, motors and other devices. The microcontroller on the board can be programmed by Arduino programming language, compiled into binary files and burned into the microcontroller. Here, I use Arduino to control the light.

Arduino can sense the environment through a variety of sensors and feed back and affect the environment by controlling lights, motors and other devices. The microcontroller on the board can be programmed by Arduino programming language, compiled into binary files and burned into the microcontroller.  

Introduction to common functions of Arduino programming language

Function introduction

digitalRead()

  • Description: reads the value of the specified digital pin

  • Function prototype: digitalRead(pin)

  • Parameter: Digital pin number to be read

  • Return value: HIGH(1) or LOW(0)

pinMode()

  • Description: configure pin input / output mode

  • Function prototype: pinMode(pin,mode)

  • Parameter: configured pin number; Configuration mode

digitalWrite()

  • Description: let the configuration output high level or low level.

  • Function prototype: digitalWrite(pin,value)

  • Parameters: PIN number, output level

analogWrite()

  • Description: realize PWM (pins 3, 5, 6, 9, 10, 11 provided in Uno) output function

  • Function prototype: analogWrite(pin,value)

  • Parameters: pin for outputting PWM wave; Specifies the pulse width, ranging from 0 to 255

Library function

sevseg.begin(hardwareConfig,numDigits,digiPins,segmentPins)

  • hardwareConfig: anode nixie tube or cathode is used.

  • COMMON_CATHODE: common cathode.

  • COMMON_ANODE: common anode.

  • numDigits: nixie tube digits.

  • digitPins: in array form, it stores the pin number of the common pole connection of the nixie tube.

  • segmenPins: in array form, it stores the corresponding connection pin numbers of nixie tubes a to dp

sevseg.setNumber(numToShow,decPlaces)

  • numToShow: data to be displayed (can be integer or floating point number)

  • decPlaces: the position where the decimal point is displayed.

sevseg.refreshDisplay()

  • Repeated execution (other delays will affect it)

Control lamp  

Let six small lights light up at the same time  

int delayTime=200;
int ledPin;
void setup() {
  // put your setup code here, to run once:
 for (ledPin = 8; ledPin <=13; ledPin++) //Set 1 ~ 6 digital pins in turn as the output mode
  { 
  pinMode(ledPin, OUTPUT); //Set the ledPin pin to output mode
  }
}

void loop() {
  // put your main code here, to run repeatedly:
  digitalWrite(8, HIGH); //Turn on the led connected to ledPin pin
  delay(delayTime);
  digitalWrite(8,LOW); //Turn on the led connected to ledPin pin
  delay(delayTime);
}

Use the switch to control six lamps to make a running water lamp  

/*
 * Digital_Button
 * Press the key to control the LED light on and off
 */

int buttonPin = 2;     // Pin definition of key
int ledPin;    // LED lamp pin definition
int delayTime =100;
void setup() {
   for (ledPin = 9; ledPin <=13; ledPin++) //Set 1 ~ 6 digital pins in turn as the output mode
  { 
  pinMode(ledPin, OUTPUT); //Set the ledPin pin to output mode
  }
  pinMode(buttonPin, INPUT_PULLUP); //Set the key pin pull-up input mode
}

void loop() {
  if (digitalRead(buttonPin) == LOW) { // If the key is pressed
    delay(20); //Wait to skip the unstable process of key jitter
    if (digitalRead(buttonPin) == LOW) // If the key is pressed
    {      
      for (ledPin = 9; ledPin <=13; ledPin++) //Turn on the led lights connected to pins 1 ~ 6 every delayTime
      {
          digitalWrite(ledPin, HIGH); //Turn on the led connected to ledPin pin
          delay(delayTime); // Turn on the LED
      }
  }
  else {   
    for (ledPin = 13; ledPin > 8; ledPin--) //Turn off the led lights connected to pins 6 ~ 1 every delayTime
    {
      digitalWrite(ledPin, LOW); //Turn off the led connected to ledPin pin
      delay(delayTime);//Delay time
    }
  }
  }
}

Use the switch to control six lights to make a running water breathing lamp  

/*
 * Digital_Button
 * Press the key to control the LED light on and off
 */

int buttonPin = 2;     // Pin definition of key
int ledPin;    // LED lamp pin definition
int delayTime =100;
void setup() {
   for (ledPin = 9; ledPin <=13; ledPin++) //Set 1 ~ 6 digital pins in turn as the output mode
  { 
  pinMode(ledPin, OUTPUT); //Set the ledPin pin to output mode
  }
  pinMode(buttonPin, INPUT_PULLUP); //Set the key pin pull-up input mode
}

void loop() {
  int t=0;
  if (digitalRead(buttonPin) == LOW)
  {
    if(t==1)
    {
      t=0;
    }else {
      t=1;
    }
  } 
    if(t==1){ // If the key is pressed
    delay(20); //Wait to skip the unstable process of key jitter
          
      for (ledPin = 9; ledPin <=13; ledPin++) //Turn on the led lights connected to pins 1 ~ 6 every delayTime
      {
          for(int fadeValue = 0 ; fadeValue <= 255; fadeValue +=5) { 
    // Output PWM
    analogWrite(ledPin, fadeValue);         
    // Wait 30 ms to observe the gradient effect
    delay(30);
                             
  } 
   
      }  
    }
  else  {   
    for (ledPin = 13; ledPin > 8; ledPin--) //Turn off the led lights connected to pins 6 ~ 1 every delayTime
    {
      digitalWrite(ledPin,LOW);
      delay(100);
    }
  }
 
}

Quark mini card making

A serial driver

Download the serial driver on the official website.

Method 1: Download CH340

  • CH340: CH340 is a USB bus transfer chip, which realizes USB to serial port, USB to IrDA infrared port or USB to print port. In the serial port mode, CH340 provides the commonly used MODEM contact signal to expand the asynchronous serial port for the computer.

  • CH340 does not support parallel port, print port and IIC. It is specially designed for serial port applications.

  • CH341 is a USB bus adapter chip, which provides asynchronous serial port, print port, parallel port and common 2-wire through USB bus

    And 4-wire synchronous serial interface.

After downloading CH340, the pre installation is successful, but the uninstallation shows that there is no driver uninstallation, and the serial port is not recognized (download failed)

Method 2: CP210x USB to UART Bridge VCP Drivers - Silicon Labs

  • Enter this website to download the driver.

  • Device successfully identified,

<!-- In fact, the reason why I didn't recognize it before should be that the computer browses Disk C by defau lt, but I'm afraid Disk C is too full and downloaded to disk F. later, I browse the updated driver. The browsed folder is changed to show that the device is working normally -- >

II. Burn image for SD card

Download the latest system image

Like raspberry pie, Quark-N can boot the system through the image burned on the SD card.

Download the open source burning software balena etcher

Burn according to the steps on the official website

Second connection serial port

Remote login and file transfer

Download puTTY serial port software

Enter the remote development board through the serial port for corresponding development

Connect WIFI

Select Serial in puTTY and fill in the host name and default Port: 112500

nmcli wifi on

dev wifi

Fill in WiFi account password

Then select SSH and fill in the router IP

So far, networking and login are completed

Log in to remote desktop

Use the shortcut key WIN+R to open and enter mstsc to log in to the remote desktop

Enter IP, user name (pi or root) and password

file transfer

Download FileZilla

It is more convenient to transfer files

LINUX

Kernel source code website: http://www.kernel.orgļ¼Œ All modifications to the Linux source code from all over the world will eventually be summarized to this website, which will be screened and modified by the open source community led by Linus, and finally decide whether to enter the Linux mainline kernel source code.

Learning videos: Embedded development live broadcast course - Application of STM32 USART serial port - maker college live broadcast room

  On the remote desktop, operate at the terminal to make the LED digital clock

After the operation is completed, my above display shows startup failure and reports errors many times. Next, I am going to format the SD card and burn it again. Most of the reasons are that I am not proficient in terminal operation.

Terminal learning

Simple command operation

Interrupt command execution: Ctrl+z

Switch Directory: cd

1. cd       Displays the current directory

2.cd..     Returns to the previous directory of the current directory

3.cd/d d:     Enter the directory where the last D disk was located

4.cd/d d:\mp4   Change the current directory to D: \ MP4

Display directory content: dir

dir     Displays subfolders and files in the current directory

dir/b     Displays the file names of subfolders and files in the current directory

dir/ad     Displays the current directory subfiles

dir/a-d   Displays the files in the current directory

dir c:\test   Displays the contents of the C: \ test directory

Create directory: md

md   work hl     Create folders named work and HL in the current directory

md d:\test   Create d: \ test directory

type c:\11.txt     Display the text content of 11.txt in disk C

Keywords: Single-Chip Microcomputer

Added by cmos on Wed, 08 Dec 2021 07:23:02 +0200