The basic case of the introduction to the Internet of Things--light-emitting diode experiment

Case 01 Light-emitting diode experiment

  1. Case goal:

To enable students to master the working principle and method of light-emitting diodes, use Arduino to write programs, compile and download programs.

  1. Case hardware equipment:

Install Arduino software on a computer, a set of UNO development boards, a light-emitting diode, a 220 ohm resistor, a breadboard, and several connections.

  1. Case effect:

 

  1. Case theory knowledge:

 

  1. Case circuit connection diagram

 

  1. Program list:

Procedure 1:

void setup() {

  // initialize digital pin 13 as an output.

  #define led 2

  pinMode(led, OUTPUT);

}

// the loop function runs over and over again forever

void loop() {

  digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)

  delay(1000);              // wait for a second

  digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW

  delay(1000);              // wait for a second

}

Procedure 2:

void setup() {

  // initialize digital pin 2  an output.

  pinMode(2, OUTPUT);

}

// the loop function runs over and over again forever

void loop() {

  digitalWrite(2, HIGH);   // turn the LED on (HIGH is the voltage level)

  delay(1000);              // wait for a second

  digitalWrite(2, LOW);    // turn the LED off by making the voltage LOW

  delay(1000);              // wait for a second

}

  1. summary:

Control the IO pin through 2, and control the LED light-emitting diode to switch once every second. Program 1 and Program 2 have the same function, please compare them, what is the difference? Please use the digital 13 port to write a program to achieve the same function?

Guess you like

Origin blog.csdn.net/m0_69311549/article/details/130573090