Arduino Basics and PWM Pins
21 Questions
0 Views

Choose a study mode

Play Quiz
Study Flashcards
Spaced Repetition
Chat to lesson

Podcast

Play an AI-generated podcast conversation about this lesson

Questions and Answers

Which pins on the Arduino UNO can be used for PWM?

  • 7, 8, 12, 13, 14
  • 1, 2, 3, 4, 5
  • 3, 5, 6, 9, 10, 11 (correct)
  • 0, 1, 2, 4, 13
  • What is the primary purpose of the analogWrite() function?

  • To set a digital output pin to HIGH or LOW
  • To write a PWM signal to a pin (correct)
  • To read the voltage of a pin
  • To configure a pin mode
  • What does the digitalRead() function return when a pin is configured as INPUT and the pin state is LOW?

  • 0V and pull-up disabled (correct)
  • 20K pull-up resistor enabled
  • 5V
  • Analog voltage value
  • How does the millis() function differ from the delay() function?

    <p>millis() does not pause program execution</p> Signup and view all the answers

    What is the effect of using the digitalWrite() function on a pin configured as OUTPUT?

    <p>Set the voltage to HIGH or LOW</p> Signup and view all the answers

    What happens when the wavelength of the PWM signal is too slow for human perception?

    <p>The LED appears to dim gradually</p> Signup and view all the answers

    What is the purpose of using the delay() function?

    <p>To pause the program for a specified duration</p> Signup and view all the answers

    What does the function micros() return?

    <p>The number of microseconds since the program started</p> Signup and view all the answers

    What does the pinMode() function in an Arduino sketch do?

    <p>Defines a pin as an input or output</p> Signup and view all the answers

    What is the purpose of the delay() function in Arduino?

    <p>To introduce a pause measured in milliseconds</p> Signup and view all the answers

    How does PWM (Pulse Width Modulation) create a fake analogue signal?

    <p>By toggling a pin high and low over time</p> Signup and view all the answers

    What is the primary function of the micros() command?

    <p>To measure elapsed microseconds since the program started</p> Signup and view all the answers

    Which function would you use to send a high digital value to a pin in an Arduino sketch?

    <p>digitalWrite()</p> Signup and view all the answers

    Which of the following correctly uses the syntax for the analogWrite() function?

    <p>analogWrite(pin, value)</p> Signup and view all the answers

    What is the primary characteristic of the setup() function in an Arduino sketch?

    <p>It initializes settings once at the start</p> Signup and view all the answers

    What is the maximum value that can be set for the duty cycle in the analogWrite() function?

    <p>255</p> Signup and view all the answers

    When using the analogWrite() function, what range of values can be sent to a pin?

    <p>0 to 255</p> Signup and view all the answers

    What feature allows a sketch to gradually light up an LED?

    <p>Fade In technique</p> Signup and view all the answers

    What does the digitalRead() function return in an Arduino sketch?

    <p>A binary value (high/low)</p> Signup and view all the answers

    Which pins on most Arduino boards are capable of using the analogWrite() function?

    <p>2, 3, 5, 6, 9, 10, 11</p> Signup and view all the answers

    In a schematic, what do the little arrows in the LED symbol indicate?

    <p>Direction of current flow</p> Signup and view all the answers

    Study Notes

    Arduino Uno PWM Pins

    • Arduino Uno can only do PWM on pins 3, 5, 6, 9, 10 and 11
    • PWM is effective for dimming LEDs when pulse frequency is faster than the eye can perceive

    Arduino Sketch Structure

    • Arduino programs are called sketches
    • Two main functions in a sketch:
      • setup(): runs once at program start, used for initialization
      • loop(): runs continuously until the board is powered off

    Arduino Functions

    • pinMode(): configures a pin as an input or output
      • Parameters:
        • pin: pin number
        • mode: INPUT, OUTPUT, or INPUT_PULLUP
    • digitalWrite(): writes a HIGH or LOW value to a digital pin
      • Parameters:
        • pin: pin number
        • value: HIGH or LOW
    • digitalRead(): reads a HIGH or LOW value from a digital pin
      • Parameters:
        • pin: pin number
    • delay(): pauses program execution for a specified amount of time in milliseconds
      • Parameters:
        • ms: number of milliseconds to pause
    • millis(): returns the number of milliseconds since the program started
      • Parameters: None
    • micros(): returns the number of microseconds since the program started
      • Parameters: None
    • analogWrite(): writes an analog value (PWM) to a pin
      • Parameters:
        • pin: pin to write to
        • value: duty cycle from 0 (off) to 255 (on)
      • Pins 5 and 6 on Uno boards have a frequency of approximately 980 Hz
      • Pins 3 and 11 on Leonardo boards have a frequency of approximately 980 Hz
      • Most other pins run at approximately 490 Hz
    • Serial: used for communication between the Arduino board and a computer or other devices
      • Communicates on digital pins 0 (RX) and 1 (TX)
      • Communicates with the computer via USB
    • Serial.begin(): initializes the serial communication

    Breadboard Guide

    • Each electronic component has a simplified drawing (schematic symbol)
    • The LED symbol has an arrow indicating the direction of current flow
    • External LEDs can be connected to a breadboard
    • The Arduino reference page offers more information on specific components

    Basic Electrical Knowledge

    • Resistors are used to limit current flow
    • LEDs require a resistor to prevent damage

    PWM (Pulse Width Modulation)

    • PWM creates a fake analog signal by toggling a pin high and low
    • The overall time spent high affects the average voltage of the signal

    Example Sketches

    • Fade In: gradually lights up an LED
    • Fade Out: gradually fades out the light of an LED
    • Fade In and Out: mimics a heartbeat by fading the LED in and out

    Studying That Suits You

    Use AI to generate personalized quizzes and flashcards to suit your learning preferences.

    Quiz Team

    Related Documents

    Introduction to Arduino PDF

    Description

    This quiz covers the fundamental concepts of Arduino programming, including the PWM (Pulse Width Modulation) pins specific to the Arduino Uno and the structure of an Arduino sketch. You'll learn about essential functions like pinMode, digitalWrite, and delay that are crucial for controlling input and output on the board.

    More Like This

    Arduino Programming and Code Comments Quiz
    10 questions
    Arduino Programming Notebook
    10 questions

    Arduino Programming Notebook

    FinestPersonification avatar
    FinestPersonification
    Arduino Uno Basic Programming
    6 questions

    Arduino Uno Basic Programming

    BeauteousSwaneeWhistle7736 avatar
    BeauteousSwaneeWhistle7736
    Use Quizgecko on...
    Browser
    Browser