analog

13

Upload: samih-jaber

Post on 13-Apr-2016

56 views

Category:

Documents


0 download

DESCRIPTION

المادة التدريبية للتدريب الثالث للفرق المشاركة في البطولة السنوية للروبوت 2016

TRANSCRIPT

Page 1: Analog
Page 2: Analog
Page 3: Analog

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).

Page 4: Analog

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).

Page 5: Analog

ANALOG READIn this example,

the sensor range

is from 3cm to

100 cm.

Page 6: Analog

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

Page 7: Analog

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.

Page 8: Analog

ANALOG WRITE (PWM)

Page 9: Analog

ANALOG WRITE (PWM)

Page 10: Analog

ANALOG WRITE (PWM)

Page 11: Analog

ANALOG WRITE (PWM)

Page 12: Analog

ANALOG WRITE (PWM)

Page 13: Analog