Podcast
Questions and Answers
Which pins on the Arduino UNO can be used for PWM?
Which pins on the Arduino UNO can be used for PWM?
What is the primary purpose of the analogWrite() function?
What is the primary purpose of the analogWrite() function?
What does the digitalRead() function return when a pin is configured as INPUT and the pin state is LOW?
What does the digitalRead() function return when a pin is configured as INPUT and the pin state is LOW?
How does the millis() function differ from the delay() function?
How does the millis() function differ from the delay() function?
Signup and view all the answers
What is the effect of using the digitalWrite() function on a pin configured as OUTPUT?
What is the effect of using the digitalWrite() function on a pin configured as OUTPUT?
Signup and view all the answers
What happens when the wavelength of the PWM signal is too slow for human perception?
What happens when the wavelength of the PWM signal is too slow for human perception?
Signup and view all the answers
What is the purpose of using the delay() function?
What is the purpose of using the delay() function?
Signup and view all the answers
What does the function micros() return?
What does the function micros() return?
Signup and view all the answers
What does the pinMode() function in an Arduino sketch do?
What does the pinMode() function in an Arduino sketch do?
Signup and view all the answers
What is the purpose of the delay() function in Arduino?
What is the purpose of the delay() function in Arduino?
Signup and view all the answers
How does PWM (Pulse Width Modulation) create a fake analogue signal?
How does PWM (Pulse Width Modulation) create a fake analogue signal?
Signup and view all the answers
What is the primary function of the micros() command?
What is the primary function of the micros() command?
Signup and view all the answers
Which function would you use to send a high digital value to a pin in an Arduino sketch?
Which function would you use to send a high digital value to a pin in an Arduino sketch?
Signup and view all the answers
Which of the following correctly uses the syntax for the analogWrite() function?
Which of the following correctly uses the syntax for the analogWrite() function?
Signup and view all the answers
What is the primary characteristic of the setup() function in an Arduino sketch?
What is the primary characteristic of the setup() function in an Arduino sketch?
Signup and view all the answers
What is the maximum value that can be set for the duty cycle in the analogWrite() function?
What is the maximum value that can be set for the duty cycle in the analogWrite() function?
Signup and view all the answers
When using the analogWrite() function, what range of values can be sent to a pin?
When using the analogWrite() function, what range of values can be sent to a pin?
Signup and view all the answers
What feature allows a sketch to gradually light up an LED?
What feature allows a sketch to gradually light up an LED?
Signup and view all the answers
What does the digitalRead() function return in an Arduino sketch?
What does the digitalRead() function return in an Arduino sketch?
Signup and view all the answers
Which pins on most Arduino boards are capable of using the analogWrite() function?
Which pins on most Arduino boards are capable of using the analogWrite() function?
Signup and view all the answers
In a schematic, what do the little arrows in the LED symbol indicate?
In a schematic, what do the little arrows in the LED symbol indicate?
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
- Parameters:
-
digitalWrite(): writes a HIGH or LOW value to a digital pin
- Parameters:
- pin: pin number
- value: HIGH or LOW
- Parameters:
-
digitalRead(): reads a HIGH or LOW value from a digital pin
- Parameters:
- pin: pin number
- Parameters:
-
delay(): pauses program execution for a specified amount of time in milliseconds
- Parameters:
- ms: number of milliseconds to pause
- Parameters:
-
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
- Parameters:
-
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.
Related Documents
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.