From the course: Learning Arduino: Pulse Width Modulation

Unlock the full course today

Join today to access over 24,000 courses taught by industry experts.

Understanding the basics of analog input

Understanding the basics of analog input - Arduino Tutorial

From the course: Learning Arduino: Pulse Width Modulation

Understanding the basics of analog input

- For this sketch, I'm going to use a potentiometer to adjust the value read on an analog input pin. I have one lead of the potentiometer connected to five volts, the other side to ground, and the center lead connected to analog input pin zero. In the Arduino IDE, I will select File, Examples, Basics, AnalogReadSerial. There are three lines of code in this sketch that may be new to you. First, in the setup function, we are initializing the serial monitor. This opens a serial communication port between the Arduino and your computer. The value of 9600 sets the maximum transfer rate of the serial port to 9600 bits per second. This is called the Baud rate, which defines how quickly information is transferred in a communication channel. A baud rate of 9600 allows 960 characters per second to be transferred. For most applications, this transfer rate is sufficient. The Arduino is capable of supporting baud rates up to 115,200, or 11,520 characters per second. Next, the Arduino will read the…

Contents