“Do not get lost in a sea of despair. Be hopeful, be optimistic.” – John Lewis
Shortly after blogging my update last week, my wife informed me that she was unable to see out of one eye. Everything was blurry. As you can imagine, that immediately changed our plans for the day. We quickly hurried off to an emergency eye doctor visit. In the world of COVID-19 that means layers of face masks, screenings and cleanings, all of which we were grateful for. By evening and after scores of tests, her vision was starting to get better. We had cleared through some of the more frightful possibilities and had a better understanding of the marvelous miracle of the eye. It is incredibly complex and can even stump intelligent eye specialists. Thankfully, my wife is doing much better but we still don’t know the exact cause, so more visits to come.
Seeing clearly is something we can easily take for granted. For those of us with glasses, we know the joy and excitement that happens when you get your first pair of glasses and suddenly realize all the details you were missing. It can be an incredibly emotional experience. Seeing and seeing clearly is one of those gifts that we often forget to appreciate. There is so much in life that is like that. These wonders and experiences become default settings. Pandemic and other life pressures can cast a sour haze over our lives. Required and important face masks and social distancing procedures have become a burden to us and discontentment rises. We are so often wrapped up in the stream of what is going wrong, that we forget to consider and enjoy what is going right.
What is going right in your life? What default ability, experience or situation are you thankful for today? As I ask myself those questions, I realize that even in the midst of emergencies and despair, there are good things to enjoy. In the middle of our struggles, there is hope. Take heart in those good things and keep up the fight. Keep moving forward. Cherish each step, each kindness passed to us and every opportunity we have to make a positive difference in someone else’s life.
May you all see clearly this week and be fortified with hope!
I love building things. During the past several weeks my girls and I have been 3D printing all sorts of characters, figures and models. It’s amazing what you can find online or build yourself with free or online tools like Tinkercad or Meshmixer. Recently we started printing with glow-in-the-dark filament. In a funny way, it unlocked a new nighttime routine for us. Before going to bed, my girls will charge up their figures by holding them next to the light to have their accompanying glow. We observed how different lights influence the glow, with the sun and UV light being the most powerful for long term glow.
Of course, this led to the question, so how does glow-in-the-dark work? I love those questions! The phosphorescence material we printed is absorbing the radiation and causing a quantum magic show where the electrons absorb the energy from the light source photons. They are jumping to a higher energy state which slowly degrades over time, emitting that glow. The unique nature of glow-in-the-dark materials like zinc sulfide and strontium aluminate is that the energy is not released immediately. The higher energy state causes the electrons to get “trapped” in a higher state and released over the course of several minutes and even hours. Quantum mechanics loves to do this forbidden magic. Ok, to be fair, I lost my girls on that explanation about the same way I lost some of you… so moving on.
How are you glowing? It is amazing to me how many metaphors surround us. This glow-in-the-dark adventure reminded me how we as humans, often radiate what we are exposed to. I often find that in my life that I begin to emit what I allow myself to be exposed to. If I become fixated on negative news, I become negative. If I spend all my time hanging around critical people, I become critical. On the flip side, if I seek and surround myself with positive people and mentors, I become more optimistic. If I change my diet to include good news as well as bad, I find that I am more encouraged and encouraging to others. What are you feasting on? What light sources are you orbiting? Who and what are you bringing into your life to help you absorb good energy so that you too can glow?
In our fast action, twitter abbreviated, news cycle world I find that I often become carried away by the currents. This little glow-in-the-dark lesson reminded me that we have a choice on where we are going and how we shape ourselves to be the people we want to be. This pandemic can be discouraging and rob us of energy and joy. There are a lot of negative and depressing conversations going on. I understand that. But we shouldn’t limit our charging to only those sources. Find some new light sources this week. Look for opportunities to jump to a higher energy state this week… and glow. Here’s to a brighter future!
The day is new. A flaming spark ignites the horizon. It arcs across the sky and warms the earth beneath. The oceans of wind crash upon the trees and grass, dancing wildly in the summer’s song. Billows of white punctuate the clear blue canopy and birds surf the invisible streams of life. Joy dances across the table, feasting upon flowers and fields of green. Onward the blaze marches until its apex erases the shadows below and floods the palace with its glory. Ebbing and flowing the wind and light shimmer, washing and painting all who live below. The day is full and the chime has come. The conductor faces the heavens and takes a bow. Slowly the shadows grow and paint the floor with cool whispers of melancholy. Deeper now the notes begin to ring as the day pulls its dark navy sheet across the sky. Memories glisten their burning specs of light in the nocturnal blanket above. Rays of the dying day stretch the shadows to their length. They gently caress the mountains and the fields. The cool tide of night rises and crashes it soft glow upon the sleepy inhabitants below. The end has come. The last glimmer bids the watcher adieu with a farewell kiss and gently folds its arms in rest.
Nothing says 4th of July like fireworks, hamburgers, watermelon… and now, Hamilton! Ok, to be fair, we didn’t set off or watch any fireworks, but we did manage to do the rest and our neighbors were happy to rattle our windows with illegal fireworks all night long. And if you didn’t catch Hamilton on Disney+, you should. It is an amazing performance! It is also a good and timely reminder that this liberty stuff is a difficult and messy business.
The right to life, liberty and the pursuit of happiness requires work, struggle and constant vigil. I was struck by those words this weekend, especially the well-chosen phrase, “pursuit of happiness.” Happiness is fleeting but it is worth pursuing. It is a constant race and requires work, energy and patience. The reward set before us is joy, happiness, a smile and a feeling of satisfaction. What does that pursuing happiness look like to you?
Happiness can be found in work. I have found that some of life’s greatest moments are at the other end of hard work and effort. There is a great happiness that can be found in a job well done, the accomplishment and the fruit of hard labor. It could be a project completed as a team at work, a repair job on the house, a problem solved, or a volunteer effort accomplished. In our knowledge worker world, that effort is more mental than muscular, but it is “work” none the less. The effort to solve complex problems and the mental energy to design, and create software, systems and processes is both taxing and rewarding. The beautiful paradox is that something that can be difficult, painful and fraught with anguish, results in a moment of happiness, delight and satisfying accomplishment.
Happiness can be found in learning. COVID-19 has presented us with a lot of difficulty but has also graced us with new time to focus and learn. In my spare time, I’m struggling to learn Japanese and my wife is polishing up on her Norwegian. I also try to strategically pick projects that help me learn something new and interesting, at work and at home. I know many of you do the same. My recent diversion has me building IoT and other electronic devices. This past weekend I decided I needed to finally learn JavaScript (and more than just copy paste coding) and built an interactive animation tool (don’t laugh) for my projects. It took a lot of work, but when I had a working model (and software is never done so you just get to MVP), I was smiling. I was happy. I wonder if we give ourselves enough challenge to be happy? Are we putting enough learning plans in our path to give us a chance to level up our knowledge and then enjoy the happiness of that moment? I think I can do more.
Happiness can be found in giving. Sure, personal rest and relaxation are good. We need to ensure we are not all work and no play. Planned time off and vacation (remember when we used to be able to travel?) are great ways to celebrate and enjoy the fruits of our labors. But I have found there is another key to unlocking happiness that isn’t about us. It is about others. I have noticed that when I invest my own energy, time and resources in helping others there is an incredible joy dividend that I get back. We are at our best when we are helping each other. Programmed into the universe and our DNA is a virtuous reciprocity that happiness comes when we consider others, prioritize their needs above our own, champion for justice, and seek to do good. I know I can do more of this.
Today, I challenge you all to think about how you are pursuing happiness. What does it look like for you? Find your path to happiness. Look for it in your work, in your learning and in your giving, then run after it and enjoy it. I wish you happiness this week and always!
“I have this ability to find this hidden talent in people that sometimes even they didn’t know they had.” – Berry Gordy
Routines are important. They create structure to manage stress, get stuff done and even unleash creative potential. In our current pandemic remote working world, routines can be a big help in creating some stability out of chaos. At the same time, they can also drive a level of monotony that can wear on your soul.
Last week I was on a call with a group of people who mentioned that it feels like we are living the movie, Groundhog Day. Each day, each meeting, each event starts to feel the same. We talked about working from different rooms or even working from outside to help mix it up. Sadly, this monotony can extend to our relationships. Most of our interactions are now digital (video conferencing, Slack and email). There is a danger that we start treating only the presentation layer. We give shallow consideration of each other to get on to the next meeting. We may do that just to survive our meeting loads. But that definitely doesn’t build depth in our relationships or bring the level of significance to our work that we want to enjoy. What can we do?
I have a radical idea. I suggest we focus some of our own energy in each meeting seeking to better understand each other. Watch, observe and take note of the unique skills you see in others. But don’t stop there, recognize them for it. Send them a note, speak up or appreciate them for what you see. Learn from them. Acknowledge them. Our hard-wired tendency is to focus on ourselves. Survival naturally depends on that, but it is singularly minded and will limit our experience, growth and impact. Instead of focusing on the video conferencing camera, turn your focus to the other people on the call. What can you do to encourage them? What do you see in others? Do you see some unique talent or skill that they may not even know? If so, tell them. We can all use encouragement.
It may be Groundhog Day again, but I suspect if we change a little of our focus, we will see the world in a whole new light. See what you can do this week to discover something new about your team members and others. For those of you with partners or kids, I suggest you try the same thing at home and see what happens. You might even spot something brilliant that even they didn’t know they had. Imagine if the whole world did that. Wouldn’t that be wonderful?
“You are where you are today because you stand on somebody’s shoulders. And wherever you are heading, you cannot get there by yourself. If you stand on the shoulders of others, you have a reciprocal responsibility to live your life so that others may stand on your shoulders. It’s the quid pro quo of life. We exist temporarily through what we take, but we live forever through what we give.” —Vernon Jordan
I thought a lot about my dad this Father’s Day weekend. He passed away five years ago in June and I still miss him. Like all fathers, he wasn’t perfect, but the lessons he taught me have had a profound impact on my life. I wanted to share some of those lessons with you today.
Be an engineer – Plan ahead. I can’t remember a single project that my dad took on that didn’t have a plan fully developed before he started. Many times, he even had written diagrams and details. He would be frustrated when we (especially my sister and I) would act without thinking ahead. It was his fundamental philosophy. He loved seeing how efficiently he could get something done. Apply engineering discipline to problems, projects and even PLAY. That’s right, he would have blueprints drawn up for our vacations (ok not exactly but they were fully planned). But it all taught me the value of engineering, being thoughtful, solving problems with design, science and planning.
Work hard – My dad was never afraid to do the hard-manual work himself, mowing lawns, repairing his car, fixing something at home or working long hours to get a job out at the office. While not unkind he had little patience for lazy people (or his own kids). He set the example with hands-on effort, blood, sweat and tears.
Be considerate – My dad would say “leave things better than you found them”. When you can, go above and beyond when dealing with others. If he borrowed something he expected to return it in better shape. Being considerate was really about the golden rule. Treat others as you would want to be treated. Don’t make others have to wait on you or clean up after you.
Details matter – Craftsmanship and precision artistry should be in all things. My dad would say, looking at a car, a tool, or anything else, “See how the seams line up? Notice the precision of the gap.” You can see and feel the quality. If you were cleaning he would help you see if you missed a spot. Underneath? Did you get the crevices? Check the edges. It taught me to have an eye for detail.
Enjoy each moment – You should savor and soak in life. Laugh and smile. Anytime we tried something new, my dad would provide instructions: slow down, observe, enjoy and taste all the flavor. That mindfulness approach to living life transcends all the chaos, turmoil and Coronavirus pandemic world we live in. It reminds me to look for the good and breathe it in. Appreciate each moment and celebrate life together.
Many of us can look back to others, our parents, grandparents, friends or mentors and think how their lessons and investments in us have made profound differences in our lives. The foundational opportunities we were given are gifts, unmerited and incredibly powerful. Not everyone receives the same investment or shoulders to stand on. As Vernon Jordan eloquently put it, if we stand on the shoulders of others, we have a reciprocal responsibility to live our life so that others may stand on our shoulders. It would be unjust for me to take what I have been given and not share it with others.
What are you doing to help others in your family, on your team or in the world? Don’t miss the great opportunity to pay it forward, encourage others, invest your talents, time, energy and resources in helping each other. Plan to make a difference in someone else. “We exist temporarily through what we take, but we live forever through what we give.”
“Character is power. If you want to be powerful in the world, if you want to be strong, influential and useful, you can be so in no better way than by having a strong character.” —Booker T. Washington
I love tea. Many of you know how much I like coffee, but you may not know how much I also enjoy tea. I have tried many teas over the years but my current favorite is PG Tips, a popular British blend of Assam, Ceylon and Kenyan teas. It’s interesting to me how they can all look and smell the same in the tea bag but can be so dramatically different after steeped. You can’t know the flavor until the hot water pulls it out from the leaves. So often in life we think we know our own character and what is core to our being, but it isn’t until the trials of life that we truly discover what is on the inside. Like tea, our true character is revealed in the hot waters of difficulty, stress, pressure and challenges. What we really are, what we have cultivated and nurtured on the inside spills out. Difficulties don’t define us, but reveal the true us.
We just crossed over the 3rd month since the start of COVID, social distancing, face masks, safer at home remote work and now economic and social justice issues. How are you doing during these difficult times? What is spilling out of you? What have you learned about yourself and others? Does it make you happy or make you want to change? These are questions I’ve been asking myself. I must confess, I feel like I’m a bit more like Decaffeinated Lipton than PG Tips. I am too easily frustrated and irritated at things that don’t go my way. I don’t always listen well (my family helped me discover this). I should be more vocal and active in supporting my fellow human brothers and sisters. I have work to do.
As the hot waters of difficulty and change washed over my family and team, I must say, I am incredibly proud. I have seen heroic characters surface in areas I didn’t expect, compassion, generosity, optimism and leadership spill out from all areas. I have also seen a river of creative problem-solving.
Sure, there have been moments when tempers flare and struggles with despair set in, but even in those moments we have had good conversations. I know that we all have a list of things we have discovered about ourselves and each other. My challenge to you today is to not let this great opportunity go to waste. As we do with all incidents, this is a great moment to study, learn and change. Be understanding. Be kind but also be brave.
What’s in your tea cup? What would you change about yourself? Your character spills out and becomes a powerful agent to influence the world around you. You matter. Your character matters. What you are inside will be revealed during difficulties. Take this opportunity to learn about yourself and cultivate a strong character so that when it spills out it becomes a powerful and useful influence on the world.
This project will show you how to build an ATtiny85 based mini Weather Station that displays temperature, humidity and pressure using four easy to read 7-segment LEDs.
Requirements
This sketch requires a version of the Wire library that is compatible with the ATtiny85 for the I2C communication to work with the BME-280 sensor. I used the ATTinyCore arduino core by Spence Konde which has a version of the Wire library that works with the ATtiny85. I was able to use the standard Adafruit_BME280 library to pull data from the BME-280. You can install ATTinyCore by putting the board manager URL in the Arduino IDE preferences:
http://drazzy.com/package_drazzy.com_index.json
Set the board to the ATtiny85 chip at 1Mhz (internal).
5V Power Supply (Alternatively you can use a 5V Solar cell, 3.7V lithium ion battery and a TP4056 constant-current/constant-voltage linear charger to charge the battery during the day).
I2C communication with BME-280 uses pins PB0/SDA and PB2/SCL. If you use the Tiny AVR Programmer from Sparkfun or something similar, keep in mind that it drives an LED on PB0 which will interfere with I2C communication. You will need to remove the chip from the programmer after uploading to get it to work in the circuit.
Memory Warning
This sketch uses nearly all of the ATtiny85 program storage space (8K) so you may get an overflow error if the libraries change or you add any code. To address this, I created a minimized BME280 library to reduce the PROGMEM space required. You will need to download and install the Tiny_BME280_Library library in:
~/Documents/Arduino/libraries/ directory and restart the Arduino IDE.
Display
[ 70'] - Temperature in degree F
[ 24r] - Relative Humidity %
[_970] - Pressure in hPa with rising/falling animation
[ 21c] - Temperature in degree C
Construction
I used two circuit boards: Display and Logic board. The Display board holds the four 7-segment LEDs with the array of resistors. On the back are header pins that plug in to the logic board. The Logic board holds the 4 register chips and the ATtiny85. On the back are headers for the Display board to plug in.
Logic and Display boards:
Both boards together and running:
I printed a simple cylinder case (Thingiverse) to mount the weather station and have it on the back patio:
Power Supply
The circuit will run on 5V or 3.3V. I used an existing solar panel, battery and TP4056 charger circuit to power this project with a 3.3V regulator.
After discovering the tiny but mighty ATtiny85 microcontroller, I decided to put it to use to help me park my car in the garage. Sure, I could continue to use the softball hung from the ceiling to let me know when I have the car pulled in far enough, but why not take advantage of some tech and have it show me instead? Alternatively, for these times, it is also a fun way to clearly demonstrate 6ft social distancing. 😉
ATiny85 Microcontroller
The ATtiny85 has 5 GPIO easily usable pins (technically you can even use Reset pin as a 6th GPIO but that makes it much more difficulty to reprogram). For information about how to program the ATtiny85, see my previous blog post here.
The tiny but mighty ATtiny85 Microcontroller Pinout
For my “Parking Helper” project I decided to use the low cost entry level ultrasonic distance sensor, the HC-SR04 and two 7-Segment LEDs to show the distance between the device and the front of the car.
HC-SR04 Ultrasonic Sensor
The HC-SR04 has 4 pins: VCC, Trig, Echo and Gnd. The Trig and Echo lines will be driven by the Attiny85.
HC-SR04 Ultrasonic Distance Sensor
The HC-SR04 measures distances by sending (TRIG) an sound pulse and measuring the time it takes for the ECHO. Sound travels through air at 332 meters per second at 20 °C (68 °F). Using this the unit provides a duration pulse back to the controller that can be used to determine the distance.
The speed of sound is: 343m/s = 0.0343 cm/uS = 1/29.1 cm/uS
I found a great project here where the author uses the HC-SR04 as an ultrasonic rule. Using the ATtiny85 to trigger and receive the duration pulse we can determine the distance to the parked car.
// Send TRIG HIGH for 10 microseconds
// to trigger the HC-SR04 to send a sound pulse
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
// Read the ECHO duration
duration = pulseIn(echoPin, HIGH);
// convert the duration to cm
distance = (duration / 2) / 29.1;
LED Display (2 Segment)
Driving the display with two 7-segment LEDs is a bit more complicated. Each segment has 7 LEDs to form the numbers plus one LED for the decimal point. That would require 8 GPIO ports for each LED Display or a total of 16 GPIOs! The ATtiny85 has only 5 available for use so we need another way. Thankfully, we can use two low cost 8-bit shift registers (74HC585) and get by with using only 3 GPIO and still drive the 16 LEDs on the two displays.
74HC595 8-bit Shift Register to Drive 7-Segment LED Display
Here is how it works… The ATtiny85 sends the binary data for the the numbers to a first 74HC595 8-bit register using its “Data Input,” “Clock” and “Latch” lines. Once the register receives a total of 8 bits (1 byte), it will overflow the data out through its “Output” line which can be connected to the “Data Input” of another register.
We toggle the “Clock” to signal to the registers to record the value of the data line (1 or 0). We do that for each of the bits of the two bytes we need sent for each display. Finally, we have the ATtiny85 toggle the “Latch” to let the registers know when the transmission is complete. They then lock the 8 output lines (QA to QH) to high or low depending on what they recorded. These lines are connected to the individual LEDs on the 7-segment LED displays.
I found a great example of using the 74HC595 to drive multiple LED Displays here. I used that code to send the data as well as the byte arrays used to form the numbers on the LEDs. Since that project was using a common anode LED and my project uses a common cathode LED I had to flip the bits. In the code below, a one (1) value would drive the LED high (on) and a zero (0) would drive it low (off).
/* Set up 7-segment LED Binary Data
|--A--|
F B
|--G--|
E C
|--D--| H - Decimal
0b00000000
ABCDEFGH
*/
numArray[0] = 0b11111100; // 0 - Zero
numArray[1] = 0b01100000; // 1 - One
numArray[2] = 0b11011010; // 2 - Two
numArray[3] = 0b11110010; // 3 - Three
numArray[4] = 0b01100110; // 4 - Four
numArray[5] = 0b10110110; // 5 - Five
numArray[6] = 0b10111110; // 6 - Six
numArray[7] = 0b11100000; // 7 - Seven
numArray[8] = 0b11111110; // 8 - Eight
numArray[9] = 0b11110110; // 9 - Nine
numArray[10]= 0b00000000; // All Off
Circuit Schematic
Pulling it all together, here is a schematic I put together that combines the ATtiny85 with the two 74HC595 registers, two LED displays and the HC-SR04 ultrasonic sensor.
A Kicad schematic is included in this project and the schematic export is sown above. The circuit is powered with a steady 5V DC supply (e.g. USB adapter). The HC-SR04 is an entry level sensor and does suffer from some fluctuation. Logic in the code attempts to stabilize the measurement by making multiple readings.
In Imperial unit mode, the code is written to display distances in inches (1 to 11) for distances less than 1 foot. Once the distance reaches 1 foot, it will show feet in decimal (1.0 to 9.9) until the distance reaches 10 feet when it will display in feet only (e.g. 10).
In SI unit mode, it will show centimeters for distances less than 1 meter (1 to 99, then it will show meters with decimal (1.0 to 9.9) until the distance reaches 10 meters and will continue to show meters only.
To toggle Units: Hold the distance to 4 (either unit) for ~4 seconds and it will toggle between units. Imperial mode will flash “in” and SI mode will flash “c”.
Sleep Feature
Sleep Mode: The code includes logic to turn off the display when there is no movement and power back on when movement is detected.
This guide will help set up a Mac OS computer to program an ATtiny 85 using the USB Tiny AVR Programmer from Sparkfun and the Arduino IDE.
Required Items:
Sparkfun Tiny AVR Programmer (Sparkfun) – This is a handy USB based programmer for ATtiny microcontrollers. It is powered by an ATtiny84 that is set up as a USBtinyISP programmer. The board has an 8 pin socket to hold a ATtiny45/85 microcontroller that you want to program.
ATtiny 85 Microcontroller (Digikey) – The ATtiny85 is a low-power 8-bit microcontroller based on the AVR enhanced RISC architecture.
Mac computer (e.g. MacBook Pro) with OS 10.14 or later
I used the following steps to get the Sparkfun Tiny AVR Programmer working on my Mac. Hopefully this will be helpful for you as well. Your experience may vary.
Step 1: Install ATtiny85
Install the ATtiny 85 into the programmer. Make sure you orient the chip so that pin 1 (usually identified by a dot) is by the notch. Once this is installed, plug the USB into your computer. You will not see a light and Mac OS will not recognize it as a serial port (don’t worry).
Install ATtiny into Programmer
Step 2: Set up Arduino IDE
Install the Arduino IDE software (Download) and navigate the menu Arduino -> Preferences and in the field for “Additional Board Manager URL” paste this link:
Click “OK” to save and restart the Arduino IDE. Navigate the menu Tools -> Board -> Boards Manger and type “attiny” into the top search board and there will click on the “Install” button on the attiny board package.
Find the attiny board package and Install.
You should now see an entry for ATtiny in the Tools > Board menu. Select “ATtiny25/45/85”.
For “Processor” select the chip you are using, e.g. ATiny85.
For “Programmer” select “USBtinyISP“
For “Clock” unless you have an external crystal in your circuit, you should select “Internal” and 1 MHz seems to be fine for most projects.
Finish by clicking “Burn Bootloader“. You should see the LED on the programmer flash. If it doesn’t work, you may need to Quit the Arduino IDE and restart to try again.
Please note: On the Mac, you do NOT select a serial “Port”. The IDE will program the ATtiny through the USBtinyISP that is loaded on the Tiny AVR Programmer board.
Step 3: Program your ATtiny85
You can use the example blink test to make sure you can program your ATtiny85. You can use the built in blink test but you will need to change the LED_BUILTIN to be 0 (zero). You can also copy and past the following code:
Arduino 1.x IDE: Click the upload button (right arrow) or press Command-U.
Arduino 2.x IDE: Select Sketch > Upload Using Programmer or Shift-Command-U
Arduino 2.x IDE – Uses “Upload Using Programmer” or Shift-Cmd-U
Once uploaded, the built-in LED should start to flash.
Example “blink” program running on ATtiny85
The ATtiny85 has PWM (Pulse Width Modulation) outputs so you can use the analogWrite() function to adjust the brightness of the LED from 0 to 255. Here is an example that fades the LED.
/*
Fade
This example shows how to fade an LED on using the analogWrite()
function.
The analogWrite() function uses PWM, so if you want to change the pin you're
using, be sure to use another PWM capable pin. On most Arduino, the PWM pins
are identified with a "~" sign, like ~3, ~5, ~6, ~9, ~10 and ~11.
*/
int led = 0; // the PWM pin the LED is attached to
int brightness = 0; // how bright the LED is
int fadeAmount = 1; // how many points to fade the LED by
void setup() {
pinMode(led, OUTPUT);
}
void loop() {
analogWrite(led, brightness);
brightness = brightness + fadeAmount;
// reverse the direction of the fading at the ends of the fade:
if (brightness <= 0) {
analogWrite(led, 0);
delay(1500);
fadeAmount = -fadeAmount;
}
if(brightness >= 255) {
fadeAmount = -fadeAmount;
}
delay(10);
}
References
This was tested on Arduino 1.x and 2.x IDEs, on an Intel i7 based Apple MacBook Pro and on an M2 based MacBook Air using an USB-C to A adapter.