72
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.
Summary of Contents for Smart Little Turtle Robot V3
Page 5: ...5 www keyestudio com 1 Introduction...
Page 16: ...16 www keyestudio com...
Page 17: ...17 www keyestudio com...
Page 18: ...18 www keyestudio com...
Page 19: ...19 www keyestudio com...
Page 22: ...22 www keyestudio com...
Page 24: ...24 www keyestudio com...
Page 25: ...25 www keyestudio com...
Page 26: ...26 www keyestudio com...
Page 28: ...28 www keyestudio com...
Page 29: ...29 www keyestudio com...
Page 30: ...30 www keyestudio com...
Page 31: ...31 www keyestudio com Step 7 Hook up Guide...
Page 32: ...32 www keyestudio com...
Page 33: ...33 www keyestudio com...
Page 44: ...44 www keyestudio com...
Page 48: ...48 www keyestudio com 4 Arduino IDE Setting Click icon open Arduino IDE...
Page 53: ...53 www keyestudio com Set board and COM port the corresponding board and COM port are...
Page 55: ...55 www keyestudio com Click to upload the program upload successfully...
Page 59: ...59 www keyestudio com...
Page 96: ...96 www keyestudio com 5 Connection Diagram...
Page 121: ...121 www keyestudio com 6 Then pop up the following page...
Page 122: ...122 www keyestudio com 7 Click Read Notify WriteWithoutResponse to enter the following page...
Page 129: ...129 www keyestudio com...
Page 143: ...143 www keyestudio com The definition inner pins are shown below...
Page 159: ...159 www keyestudio com 3 Connection Diagram 4 Test Code...
Page 167: ...167 www keyestudio com 2 Hook up Diagram...
Page 187: ...187 www keyestudio com 8 8 LED matrix shows rightward icon Flow Chart 2 Hook up Diagram...
Page 200: ...200 www keyestudio com 5 Click to enter the main page of turtle smart car...