Search Code

Lesson 14/31: Arduino Millis (no delay) and map functions | SunFounder Robojax

Бұл сабақтың бөлігі: Arduino Course based on SunFounder's 3-in-1 Learning Kit

Lesson 14/31: Arduino Millis (no delay) and map functions | SunFounder Robojax

Introduction

This lesson teaches two essential Arduino functions: millis() and map(). By the end of this tutorial, you will understand:

  • How to use millis() to manage timing without stopping program execution.

  • How to use map() to scale and control values, such as LED brightness or motor speed, based on percentages.

Part 1: Understanding millis()

The millis() function returns the number of milliseconds since the Arduino started running. It's crucial for creating non-blocking code where multiple tasks run simultaneously.

Why Use millis() Instead of delay()?

  • The delay() function pauses the entire program, preventing other code from running.

  • millis() lets you perform actions at specific intervals while the rest of your code continues executing.

Example: Blink LED Without delay()

Код жоқ.

Ресурстар мен сілтемелер

Әлі ресурстар жоқ.

Файлдар📁

Arduino кітапханалары (zip)