analog
DESCRIPTION
المادة التدريبية للتدريب الثالث للفرق المشاركة في البطولة السنوية للروبوت 2016TRANSCRIPT
ANALOG READ• One of the Arduino Uno digital pins is
connected to an input analog device.
• We want to know what value the device is
reading (e.g. a sensor for distance).
• Use the analogRead function to do so.
• ReadVar = analogRead (pinVar).
ANALOG READ• The analog read function returns a value
between 0 and 1023.
• To get a useful value, we want the value read
to be consistent with the range of the device.
• Use the map function:
SensorVal = map (ReadVar, 0 , 1023, x, y).
ANALOG READIn this example,
the sensor range
is from 3cm to
100 cm.
ANALOG WRITE (PWM)• PWM stands for Pulse Width Modulation.
• PWM enables controlling the “intensity of the
output”.
• Devices for analog output can only be connected to
(~) marked pins on Arduino Uno: 3, 5, 6, 9, 10, 11
ANALOG WRITE (PWM)• In this case, there is no need to declare the
pins as outputs in the setup.
• The function used: analogWrite (pin, Value);
• “Value” must be between 0 and 255.
• 0 means no output potential.
• 255 means maximum output potential.
ANALOG WRITE (PWM)
ANALOG WRITE (PWM)
ANALOG WRITE (PWM)
ANALOG WRITE (PWM)
ANALOG WRITE (PWM)