Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 6 Current »

Analog vs. Digital

  • Arduinos are digital devices – ON or OFF. Also called discrete

  • Analog signals are anything that can be a full range of values. Examples?

Digital Signal

Analog Signal

  • Arduino does not generate true analog outputs. The instantaneous output is always 0V or 5V.

  • How do we generate the effect of analog using digital?

Pulse Width Modulation (PWM)

  • To create (mimic) an analog signal, the Arduino uses a technique called Pulse Width Modulation (PWM). By varying the duty cycle, we can mimic an “average” analog voltage

analogWrite()

C++

Blocks

Using a variable val

analogWrite(pin, val);
image2020-1-21_19-10-22.png

Note : The example above shows pin 11 being used. We can't use a variable for pin number with Blocks

Using a constant (hard-coded) val

analogWrite(3, 128);
image2020-1-21_19-10-51.png

pin – refers to the OUTPUT pin (limited to pins 3, 5, 6, 9, 10, 11.) – denoted by a ~ symbol

val – 8 bit value (0 – 255). 

0 => 0V

255 => 5V 

image2019-7-31_17-14-47.png

  • No labels