This project uses one LED connected to Arduino, it makes a dimming and flashing effect. This project is good for starting point of Analog Output and PWM learning, while reviewing Digital Output, Analog Input, practice "for-looping" and serial communications. Step-by-step tasks are designed for good learning progress, this project can be used across 1-2 learning sessions in class. Goals:
Understand Analog Output and PWM concept
Analog output in Arduino, analogWrite(), and map() to re-arrange resulted range
Comprehensive practice of analogRead(), for-loop and digitalWrite()
START A BIT > Projects Library > This page
Demo of the dimmable LED using potentiometer (Task 3)
Demo of the cross-dimming LEDs (Challenging Task 4)
[ ] Simple: 30-60 minutes
[ ] Moderate: 1-2 hours
[x] Challenging: more than 2 hours
The estimation bases on average situation without unexpected troubleshooting, assuming that the student meets prerequisites. It only indicates rough time needed to complete this project, but not about technical difficulty, not covering discussion and sharing time.
One should have prior knowledge
Purpose: Understand how to output PWM signal in Arduino, practice with for-loop
Possible to take this task in virtual setup by Tinkercad, for hardware wiring and coding, simulation
Don't use built-in LED, the dimming effect is not so visible
Need to use PWM capable pin, only some part of digital output pins support PWM, on UNO, it's pin 3, 5, 6, 9, 10, 11
Read the codes as reference, write your own code and make a working result
Test and analyze how it works by help from serial print
What are the min and max value for analogWrite?
Have we missed pinMode(A0, INPUT)?
Purpose: Consolidate core knowledge based on Task 1
Read the codes as reference, write your own code and fix the red-marks to make a working result
Test and analyze how it works
What is the difference between analogWrite() and digitalWrite()?
How about replacing line 23 by analogWrite(LED_PIN, 0)?
How about replacing line 25 by analogWrite(LED_PIN, 255)?
Purpose: Comprehensive task for both analogRead() and analogWrite(), as well as map()
We want to use potentiometer to smoothly change LED brightness by rotating the bar
Read the codes as reference, write your own code and fix the red-marks to make a working result
What is the value range of from analogRead() in Arduino UNO?
What is the acceptable value range of analogWrite() in Arduino UNO?
Purpose: Creative task as an optional challenge task
Based on Task 3, we add another LED, and want to see the 2 LEDs cross-dimming when rotating the potentiometer
This is a challenging task, without reference codes, please explore and make a working result
Be careful to select PWM compatible digital output pins
Use map() to map different result ranges
Use Serial.print() to write helpful debugging logs
Purpose: Enhance basic knowledge understanding, reflect and summarize what we have learnt
What is analog output?
Is PWM a real analog output?
What is the acceptable value range of analogWrite() in Arduino UNO?
Take 1-2 minutes to explore anything on the tools and the making flow, with curiosity, no matter how much prior knowledge you have, you should make
At least 1 interesting finding
At least 1 curious question
Used by LP2536.A: PWM Output, 25w36