Keyestudio Smart Little Turtle Robot V3 Manual page 72

Table of Contents

Advertisement

www.keyestudio.com
The two"for"statements make value increase from 0 to 255, then reduce
from 255 to 0, then increase to 255,....infinitely loop
There is a new function in the following ----- analogWrite()
We know that digital port only has two state of 0 and 1. So how to send an
analog value to a digital value? Here,this function is needed. Let's observe
the Arduino board and find 6 pins marked " ~ " which can output PWM
signals.
Function format as follows:
analogWrite(pin,value)
analogWrite() is used to write an analog value from 0~255 for PWM port,
so the value is in the range of 0~255. Attention that you only write the
digital pins with PWM function, such as pin 3, 5, 6, 9, 10, 11.
PWM is a technology to obtain analog quantity through digital method.
Digital control forms a square wave, and the square wave signal only has
two states of turning on and off (that is, high or low levels). By controlling
the ratio of the duration of turning on and off, a voltage varying from 0 to
5V can be simulated. The time turning on(academically referred to as high
level) is called pulse width, so PWM is also called pulse width modulation.
Through the following five square waves, let's acknowledge more about
PWM.
72

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents