Arduino

studied byStudied by 69 people
5.0(2)
Get a hint
Hint

PWM

1 / 62

flashcard set

Earn XP

Description and Tags

torture

Engineering

63 Terms

1

PWM

A technique that allows you to simulate an analog signal using digital means

New cards
2

PWM values range

[0, 255]

New cards
3

potentiometer values range

[0, 1023]

New cards
4

Wire color conventions

  • Black: ground 

  • Red: 5V

  • Orange: 3.3V

  • Other colors for signal wires

New cards
5

digital pins

  • allows you to connect digital sensors and other integrated circuits

  • allow you to read digital inputs and control outputs

  • digital signals are either HIGH (1) or LOW (0)

  • pins 0-13 for GPIO

  • digital pins 3, 5, 6, 9, 10, 11 have a ~

    • allows you to perform PWM

<ul><li><p>allows you to connect digital sensors and other integrated circuits</p></li><li><p>allow you to read digital inputs and control outputs </p></li><li><p>digital signals are either HIGH (1) or LOW (0)</p></li><li><p>pins 0-13 for GPIO</p></li><li><p>digital pins 3, 5, 6, 9, 10, 11 have a ~</p><ul><li><p>allows you to perform PWM </p></li></ul></li></ul>
New cards
6

Analog In

  • used to read analog inputs

  • analog signals can take an infinite number of values within a range of values

  • A0 - A5 used to input analog signal from Arduino

New cards
7

Arduino measures the value of analog signals by using ___, which converts ___ to ___

analog-to-digital converter (ADC); analog voltage; digital value

New cards
8

Analog voltages are converted to digital values from the range __

[0, 1023]

New cards
9

pushbuttons (momentary switch)

  • Push button → make connection → current flows from one of the side of the switch to the other side of the switch

  • Metal bar connects pins A and B

  • Metal bar connects pins C and D 

  • Closing switch → connection pints A & B with pins C & D → allows current to pass through switch

<ul><li><p><span>Push button → make connection → current flows from one of the side of the switch to the other side of the switch</span></p></li><li><p><span>Metal bar connects pins A and B</span></p></li><li><p><span>Metal bar connects pins C and D&nbsp;</span></p></li><li><p><span>Closing switch → connection pints A &amp; B with pins C &amp; D → allows current to pass through switch</span></p></li></ul>
New cards
10

use ___ to read button state

digitalRead(btnPin)

New cards
11

To send PWM value from Arduino to RGB LED, use ___

analogWrite(pin, value)

Examples:

  • analogWrite(redPin, 255) – red on at 100% intensity

  • analogWrite(redPin, 0) – red off (on at 0% intensity)

  • analogWrite(redPin, 127) – red on at 50% intensity

New cards
12

The longest pin of an RGB LED is the _____

common cathode

<p>common cathode</p>
New cards
13

The common cathode of an LED is connected to (5V/Ground)

ground

New cards
14

purpose of delayMicroseconds()

delay the operation for specified microseconds

New cards
15

When writing code for a range finder, use ___ to set the trigPin to HIGH or LOW

digitalWrite(trigPin, HIGH)

digitalWrite(trigPin, LOW)

New cards
16

what does pulseIn(echoPin, HIGH) do?

receive the echo signal and returns soundwave travel time in microseconds.

New cards
17

analogWrite()

used to send a PWM value from the Arduino to the LED’

  • analogWrite(pin, value)

    • Pin - arduino PWM pin 

    • Value - integers in range [0, 255]

<p>used to send a PWM value from the Arduino to the LED’</p><ul><li><p><strong><span>analogWrite(pin, value)</span></strong></p><ul><li><p><span>Pin - arduino PWM pin&nbsp;</span></p></li><li><p><span>Value - integers in range [0, 255]</span></p></li></ul></li></ul>
New cards
18

How to avoid floating pin

Connect the switch to ground using a very large resistor (10 kΩ). If any signals are detected while the button is not pressed, the large resistance will reduce the signal level to almost zero keeping the state LOW.

New cards
19

Debouncing

Add a timing delay of 10ms to wait out the contact bounce period

New cards
20

How does a rangefinder work?

Transmitter (trig pin) sends a sonic burst that travels at the speed of sound.
The sound wave will reflect off the object creating an echo wave.
The echo wave is received by the receiver (echo pin).
Echo pin outputs the time in microseconds that the sound wave traveled.

New cards
21

Formula to calculate object distance based on time echo pin outputs

d = 0.034(t/2)

Object Distance (cm) = speed of sound (cm/μs) * time (μs) /2

New cards
22

when using a range finder, connection Vcc and GND to the wrong places results in a ___

short circuit

New cards
23

the trig pin and echo pin of a range finder can be connected to any ___

digital pin

New cards
24

Temperature sensor is an ___ input

analog

New cards
25

Formulas for temperature sensor

VOUT = reading from ADC • (5000/1024)
Temperature (°C) = (VOUT - 500)/10

New cards
26

Orientation of temperature sensor

flat face should face you

<p>flat face should face you </p>
New cards
27

use ___ to read input from temperature sensor

analogRead(tempPin)

New cards
28

Unpolarized light

light that vibrates in multiple directions

New cards
29

Polarized light

light that vibrates in one direction

New cards
30

Polaroid Filter

blocks one of the two planes of vibration of an electromagnetic wave, polarizing it.

New cards
31

LCD

Liquid Crystal Display

New cards
32

Reflective LCD

uses a mirror to reflect environmental light

New cards
33

Backlit LCD

LEDs are used to provide the light source

New cards
34

Purpose of I2C

reduces the number of data pins from 6 to 2 by using the SDA (Signal Data) and SCL (Signal Clock) pins on the Uno instead of digital I/O pins.

<p><span>reduces the number of data pins from 6 to 2 by using the SDA (Signal Data) and SCL (Signal Clock) pins on the Uno instead of digital I/O pins.</span></p>
New cards
35

A potentiometer is an ____

Analog Sensor

New cards
36

linear interpolation setup

map(value, 0, 1023, 0, 255)

map(value, fromMin, fromMax, toMin, toMax)

Use linear interpolation to map given value in [fromMin, fromMax] to corresponding value in [toMin, toMax]

New cards
37

Arduino simulates analog signals using PWM. Instead of varying supply voltage and rapidly switching between HIGH and LOW, it uses the ___ voltage provided

average

<p>average</p>
New cards
38

read potentiometer value using ___

analogRead(potentiometer)

New cards
39

When using a potentiometer, if you connect 5V to terminal 2, which way would you turn the potentiometer to increase the values?

clockwise (this orientation is used most often)

New cards
40

When light exposure is light, photoresistors have __ resistance

low (∼1 kΩ)

New cards
41

When light exposure is dark, photoresistors have __ resistance

high (∼ 10 kΩ)

New cards
42

How do arduino analog pins measure a photoresistor’s change in voltage?

Since arduino analog pins measure change in voltage, to measure photoresistor’s resistance, a 10 kΩ resistor is used to create small current. This allows arduino to measure voltage across photoresistor

New cards
43

when using a photoresistor, voltage at pin is measured using ___ function

analogRed(photoResistor)

As the amount of light detected increases, the value returned will increase.

New cards
44

electric motors convert _ energy to mechanical energy

electrical

New cards
45

How are DC motors able to turn?

In a DC motor, a wire with current running through it is passed through a magnetic field → magnetic force produces torque → turns motor. Commutator reverses current each half turn to keep torque turning motor in same direction.

New cards
46

Motors act as __

inductors

  • Stores energy in magnetic filed

  • Opposes sudden changes in current

New cards
47

an __ controls motor direction

H-bridge

  • To control rotation direction, reverse direction of current flow into motor 

  • Speed of motor controlled by PWM

  • H-bridge, a circuit, reverses direction of current flow

<p>H-bridge </p><ul><li><p><span>To control rotation direction, reverse direction of current flow into motor&nbsp;</span></p></li><li><p><span>Speed of motor controlled by PWM</span></p></li><li><p><span>H-bridge, a circuit, reverses direction of current flow</span></p></li></ul>
New cards
48

Why do motor dead zones exist?

  • Sufficient voltage needs to be supplied to overcome friction in motor for shaft to turn 

  • If voltage is insufficient, buzzing sound will occur 

  • To prevent buzzing, PWM value of minimum speed is required to get the motor to turn 

    • Use this threshold value as the dead-zone 

    • Any motor speed value below threshold results in motor remaining OFF

New cards
49

If motor is not carrying load, don’t….

run motor at max. speed. keep PWM value below 150

New cards
50

which coding function is used to control motor direction

digitalWrite()

digitalWrite(in1, HIGH) - turn motor in forward direction

digitalWrite(in1, LOW) - turn motor off

New cards
51

To reverse motor, how would you modify the linear interpolation setup?

map(potValue, 0, 512, 0, 255) → map(potValue, 0, 512, 255, 0)

  • second range is reverse so max. speed occurs when knob is turned fully left

<p><span>map(potValue, 0, 512, 0, 255) → </span><strong>map(potValue, 0, 512, 255, 0)</strong></p><ul><li><p>second range is reverse so max. speed occurs when knob is turned fully left </p></li></ul>
New cards
52

Coding conventions

  1. Import necessary libraries 

  2. Include a program header that includes your name, section, assignment/program function 

  3. Define constants and variables

    1. Be consistent 

    2. Do not mix and match camCase or under_scores 

    3. Use descriptive names 

  4. Define void setup()

    1. Initialize pin modes, libraries, etc

    2. pinMode(), Serial.begin(9600),

  5. Define void loop()

    1. Always keep code in the void loop 

    2. This is the “main” program 

    3. Use helper functions 

  6. Define helper functions

    1. Don’t Repeat Yourself - DRY

    2. Create reusable, modular code  

  7. Comment your code 

    1. Avoid obvious comments 

    2. Comments should help non-coder follow the program’s logic

New cards
53

fill in the blank: pinMode(trigPin, ____)

OUTPUT

New cards
54

fill in the blank: pinMode(echoPin, ____)

INPUT

New cards
55

fill in the blank: pinMode(photoResistor, ____)

INPUT

New cards
56

anatomy of Ultrasonic sensor/range finder

  • Vcc - connected to 5V

  • Gnd - Ground

  • Trig - trigger (transmits sonic pulse)

  • Echo - receives the echo pulse

<ul><li><p><strong><span style="color: red">Vcc</span></strong><span> - connected to 5V</span></p></li><li><p><strong><span>Gnd</span></strong><span> - Ground</span></p></li><li><p><strong><span style="color: yellow">Trig</span></strong><span> - trigger (transmits sonic pulse)</span></p></li><li><p><strong><span style="color: green">Echo</span></strong><span> - receives the echo pulse</span></p></li></ul>
New cards
57

Analog signal

  • smooth, continuous curve 

    • Range: real numbers 

    • Used for temperature, sound intensity, light intensity 

    • Used for resistors, capacitors, inductors, diodes, transistors, and operational amplifiers

      • Circuits with these components are analog

      • Can be more difficult to design 

    • Susceptible to noise 

      • Small voltage variations - can result in processing errors 

New cards
58

Digital Signal

  • series of discontinuous levels (step function)

    • Range: real numbers 

    • Width of the step is determined by sampling rate 

      • Faster sampling rate = reduced step width and increased signal accuracy 

      • Music sampling range is from 8 kHz to 22.6 MHz

    • Used for signals for microcontrollers 

    • Signals have different logic levels 

      • High: 5V, 3.3V, 1,8V

      • Low: 0V

    • Easier to design than analog circuit but more expensive

New cards
59

Faster sampling rates __ width of step, which increases the accuracy of the analog to digital conversion

reduce

New cards
60

How to import library

Tool → Manage Libraries → search for the thing → download thing

New cards
61

What does a capacitor do?

it reduces noise

noise is small, undesired voltage variations

New cards
62

What is contact bounce?

metal contacts come together and bounce because of spring-like properties

New cards
63

LED anatomy

longer leg: anode (+)

shorter leg: cathode (-)

current flow from anode → cathode

<p>longer leg: anode (+)</p><p>shorter leg: cathode (-)</p><p>current flow from anode → cathode</p>
New cards

Explore top notes

note Note
studied byStudied by 18 people
... ago
5.0(1)
note Note
studied byStudied by 11 people
... ago
5.0(1)
note Note
studied byStudied by 8 people
... ago
5.0(1)
note Note
studied byStudied by 9 people
... ago
5.0(1)
note Note
studied byStudied by 11 people
... ago
5.0(2)
note Note
studied byStudied by 25 people
... ago
5.0(2)
note Note
studied byStudied by 56 people
... ago
5.0(1)

Explore top flashcards

flashcards Flashcard (81)
studied byStudied by 22 people
... ago
5.0(1)
flashcards Flashcard (31)
studied byStudied by 1 person
... ago
5.0(1)
flashcards Flashcard (85)
studied byStudied by 91 people
... ago
5.0(3)
flashcards Flashcard (22)
studied byStudied by 12 people
... ago
5.0(1)
flashcards Flashcard (30)
studied byStudied by 2 people
... ago
5.0(1)
flashcards Flashcard (280)
studied byStudied by 18 people
... ago
5.0(1)
flashcards Flashcard (31)
studied byStudied by 31 people
... ago
5.0(1)
flashcards Flashcard (39)
studied byStudied by 35 people
... ago
5.0(1)
robot