Test light strength test task 10

Test light strength test task 10

Program Interpretation:

int x; // define the variable x, preservation of digital port

int y; // define the variable y, saving read data A0

void setup () // initialize variables, mode setting pin

{

  for (x = 3; x <= 4; x ++) // for (initializing portion; condition judging part; portion increment data)

  {

    pinMode (x, OUTPUT); // configured as output pins

   }

}

void loop () // programs and changes state in response to events

{

  y = analogRead (A0); // Read Analog pins A0, returns a value between [0-1023]

  if (y> 30) // comparison operators used in combination, to test whether certain conditions are met

  {

    digitalWrite (3, HIGH); // write the digital pins, pins corresponding to high

    delay (1000); // 1 second delay

  }

  if (y> 80) // When the data is greater than 80

  {

    digitalWrite (3, LOW); // write the digital pins, corresponding to low pin

    digitalWrite (4, HIGH); // write the digital pins, pins corresponding to high

    delay (1000); // 1 second delay

Guess you like

Origin www.cnblogs.com/ztg1/p/12554909.html