Arduino

5.0(2)
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/62

flashcard set

Earn XP

Description and Tags

torture

Engineering

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

63 Terms

1
New cards

PWM

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

2
New cards

PWM values range

[0, 255]

3
New cards

potentiometer values range

[0, 1023]

4
New cards

Wire color conventions

  • Black: ground 

  • Red: 5V

  • Orange: 3.3V

  • Other colors for signal wires

5
New cards

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>
6
New cards

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

7
New cards

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

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

8
New cards

Analog voltages are converted to digital values from the range __

[0, 1023]

9
New cards

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>
10
New cards

use ___ to read button state

digitalRead(btnPin)

11
New cards

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

12
New cards

The longest pin of an RGB LED is the _____

common cathode

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

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

ground

14
New cards

purpose of delayMicroseconds()

delay the operation for specified microseconds

15
New cards

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

digitalWrite(trigPin, HIGH)

digitalWrite(trigPin, LOW)

16
New cards

what does pulseIn(echoPin, HIGH) do?

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

17
New cards

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>
18
New cards

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.

19
New cards

Debouncing

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

20
New cards

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.

21
New cards

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

22
New cards

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

short circuit

23
New cards

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

digital pin

24
New cards

Temperature sensor is an ___ input

analog

25
New cards

Formulas for temperature sensor

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

26
New cards

Orientation of temperature sensor

flat face should face you

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

use ___ to read input from temperature sensor

analogRead(tempPin)

28
New cards

Unpolarized light

light that vibrates in multiple directions

29
New cards

Polarized light

light that vibrates in one direction

30
New cards

Polaroid Filter

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

31
New cards

LCD

Liquid Crystal Display

32
New cards

Reflective LCD

uses a mirror to reflect environmental light

33
New cards

Backlit LCD

LEDs are used to provide the light source

34
New cards

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>
35
New cards

A potentiometer is an ____

Analog Sensor

36
New cards

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]

37
New cards

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>
38
New cards

read potentiometer value using ___

analogRead(potentiometer)

39
New cards

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)

40
New cards

When light exposure is light, photoresistors have __ resistance

low (∼1 kΩ)

41
New cards

When light exposure is dark, photoresistors have __ resistance

high (∼ 10 kΩ)

42
New cards

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

43
New cards

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.

44
New cards

electric motors convert _ energy to mechanical energy

electrical

45
New cards

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.

46
New cards

Motors act as __

inductors

  • Stores energy in magnetic filed

  • Opposes sudden changes in current

47
New cards

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>
48
New cards

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

49
New cards

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

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

50
New cards

which coding function is used to control motor direction

digitalWrite()

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

digitalWrite(in1, LOW) - turn motor off

51
New cards

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>
52
New cards

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

53
New cards

fill in the blank: pinMode(trigPin, ____)

OUTPUT

54
New cards

fill in the blank: pinMode(echoPin, ____)

INPUT

55
New cards

fill in the blank: pinMode(photoResistor, ____)

INPUT

56
New cards

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>
57
New cards

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 

58
New cards

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

59
New cards

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

reduce

60
New cards

How to import library

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

61
New cards

What does a capacitor do?

it reduces noise

noise is small, undesired voltage variations

62
New cards

What is contact bounce?

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

63
New cards

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>