Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Arduino Essentials
  • Toc
  • feedback
Arduino Essentials

Arduino Essentials

By : Perea
5 (5)
close
Arduino Essentials

Arduino Essentials

5 (5)
By: Perea

Overview of this book

If you are a hobbyist who wants to develop projects based on Arduino as the main microcontroller platform or an engineer interested in finding out what the Arduino platform offers, then this book is ideal for you. Some prior knowledge of the C programming language is required.
Table of Contents (12 chapters)
close
11
Index

Analog control through code

The most valuable part of this example is not its physical part but its logical one, and I'll show you the associated functions to deal with analog outputs and a very important control structure in any programming language called a for loop in the code we will be using for this circuit.

The analogWrite() function

Dealing with analog outputs from the programming side is just a matter of using the analogWrite() function, which, as its name implies, writes an analog value through a pin.

It takes two parameters, similar to the digitalWrite() function:

  • The first one is the pin on which we want to operate (remember that it has to be one marked as PWM) on
  • The second parameter is the value we want to output, and that, as I told you previously, can take any value in the range of 0 to 255, 0 meaning 0V and 255 meaning 5V

The for loop

The other important concept we will come across in this example is a for loop, which is a very important control structure present in almost...

bookmark search playlist font-size

Change the font size

margin-width

Change margin width

day-mode

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Delete Bookmark

Modal Close icon
Are you sure you want to delete it?
Cancel
Yes, Delete