Keep Learning

“The illiterate of the 21st century will not be those who cannot read and write but those who cannot learn, unlearn, and relearn.” – Alvin Toffler

As a kid, I was inspired by movies like TRON to explore computers.  I caught the bug as soon as I saw how easily software could be used to shape reality and improve things.  I spent 6 years skipping around between computer science, mathematics, physics, electrical and civil engineering.  I even invested a year working toward a masters in divinity until I realized Koine Greek wasn’t a new computer language.  

My dad was a civil engineer with crazy mad RPN calculator skills. He could crank out and tabulate thousands of calculations per day.  But one day I wrote a bit of software and suddenly a week’s worth of tedious error prone work was done in minutes.  He immediately hired me to “computerize” the rest of his business.  With my educational background, I thought I was set… I could change the world (or at least my corner of it), one program at a time… but I still had a lot to learn. I soon discovered I didn’t know enough about statics and dynamics for the structural engineering work I needed to do.  I also needed to dive deeper into 3D geometry and computer graphics for modeling complex systems.  I went back to school.

There is a thought that education is just a box you need to check to begin your career.  You may get certified, degreed or licensed and now you are done, right?  Nope! Those are all great, but they are just visible footprints on the stairway of continual learning.  Learning expands the mind and prepares us for more learning.  Each step along the way reveals new vistas of knowledge to explore, new puzzles to solve and new mastery to obtain.  We are forever on this learning adventure, growing and thriving on the food of knowledge, discovery and experimentation.  Every new cognitive challenged unlocked is like an awakening.  It is the physics of life.  Each discovery expands who we are and carries us to a new level.  We are alive and growing when we are learning.

Learning can be fun, but it isn’t easy.  It takes work.  It can be exhausting and even frustrating at times.  Because of that, there is a temptation to become comfortable with our current state.  We may find we can get by with what we already know, often for years without having to learn something new.  But we aren’t growing.  We become stale.  Our capacity to move ourselves, our teams and our organization forward, withers.  Like physical exercise, mental exercise is required to stay healthy, vibrant and alive.  Just as we should plan to exercise our physical bodies to stay healthy, we should plan to exercise our minds as well. 

What are you learning?  May I suggest, if you aren’t learning anything new right now, pick something new and start learning it today?  I know it isn’t easy, but embrace the constructive discomfort and expand your knowledge and skill.  Tackle it.  Imagine yourself thriving and growing.  Don’t limit yourself. Set a goal to upgrade your knowledge every week.  Study, grow and keep learning!

A Sonic Revolution

“We knew it could become big but could have never imagined it would be a revolution.” – Lou Ottens

Magnetic tape was genius!  A ferric oxide placed on a thin plastic film allowed the world to record, store and playback audio.  It revolutionized broadcasting, radio and especially, music.  In 1960, the portability of that music was still captured in a clumsy 7-inch reel.  It wasn’t easy to play. You needed a hefty machine the size of a small suitcase.  Lou wasn’t happy with that.  

Lou loved technology.  He was ever the engineer and loved solving problems.  As a teenager during World War II, Lou made a radio for his family so they could listen to programs like Radio Oranje.  To avoid the Nazi jammers, he even constructed a primitive directional antenna.  Just as he had made those freedom broadcasts accessible to his family, he now turned his attention to democratizing music.

The 7-inch music reel was too bulky and awkward for the general population.  He wanted music to be portable and accessible.  He thought a lot about what it should be like.  Trying to envision something that didn’t yet exist, he began shaping it into a small wooden block.  It needed to be small enough to easily fit in your hand and more importantly, fit in your pocket.  His “compact cassette” tape came to life in 1963 and quickly became a must-have sensation across the world.  It unleashed a multi-billion dollar industry but also taught us how to use our own voice.  The cassette became an audio canvas for the masses to self-create their own albums or compile their own mixtapes to share with others.  For those of you who don’t have as many candles on your cake as I do, mixtapes were basically the playlists of the 1980s.

The cassette tape was a raging success, but Lou wasn’t happy with it.  He complained about the noise and distortion that would eventually plague the aging tapes. In his mission for higher fidelity, he worked with his company, Philips and Sony to co-develop the digital optical storage system, the compact disk (CD).  As he had done with the cassette tape, Lou championed a portable disk size that could be easily held and used.

Lou Ottens passed away earlier this month, at the age of 94.  He sparked a worldwide sonic revolution, but humbly dismissed his role as nothing special, instead crediting other engineers and designers for bringing his ideas to life.  Lou reminds us that making science and technology accessible is just as important as the discovery itself.  

Do we make our complex technical inventions and solutions accessible?  When technology is done well, the technology itself fades to the background and becomes “indistinguishable from magic”.  That is to say, it provides a human experience and value and doesn’t get in the way.  My challenge to us this week is to examine the solutions we deliver and ask ourselves, can we make them more accessible and magical?  

As Lou taught us, the genius of a great idea is not just in the science, it is making that technology portable and accessible.

Restlessly Pursue Learning

“We now accept the fact that learning is a lifelong process… And the most pressing task is to teach people how to learn.” – Peter Drucker

It was hard for little Bill to sit still. He was ready to run into the world, pushing through barriers and making a difference.  He was a natural leader and soon became the first black student body president of Foshay Middle School in Los Angeles.  He continued to break norms by being the first black student body president at Polytechnic High School before graduating with honors.  He went on to get a degree at UC Berkeley before being drafted into the U.S. Army.  He served 2 years during the Korean War, attaining the rank of Captain.

After the Army, Bill enrolled in the pre-med program at UCLA.  He was accepted as the first African American medical student.  After graduating he interned at Harbor General Hospital.  He specialized in obstetrics and gynecology and opened two women’s clinics in Los Angeles.  He later became the first African-American resident at Queen of Angels Hospital in Los Angeles.  Bill loved people and had a special affection for children.  He served his longest time at Cedars-Sinai Medical Center, where he once held the record for the most infants delivered.  

Forever learning, restless and driven, Bill at the age of 52 and after 14 years of medical practice, returned to school and received his J.D. from Southwestern University School of Law.  After passing the bar, he worked as a forensic attorney helping victims in malpractice suits.  He served on the Board of Governors of the UCLA Foundation and even after retiring, went back to practice medicine and law until his passing.  Through his life, he touched so many other lives.  His impact was far reaching and he was even recognized by the U.S. Congress for his life’s work and achievements. 

Bill’s life reminds us that we can all restlessly pursue learning and improvement.  We can challenge the limits others place on us or we place on ourselves.  I hope Bill’s story inspired you as it did me.  Keep learning.  Keep striving.  Keep helping.  We can make this world a better place, if we try.  And, like Bill, we can also leave behind a legacy that can inspire the next generation. 

Oh, and one more thing…  Dr. Lawrence William “Bill” Scott not only left behind a legacy of “firsts”, he also passed on his passion of science and the restless pursuit of learning through his children.  You might know at least one of them.  His son is a leader at Disney and in the industry, a champion of technology and the restless pursuit of learning, Brian L. Scott.

Keep learning!

A Pocket of Curiosity

“I’m just very curious—got to find out what makes things tick… all our people have this curiosity; it keeps us moving forward, exploring, experimenting, opening new doors.” – Walt Disney

Percy Spencer only had a fifth-grade education. His father passed away when he was a toddler and he left school to get a job to support his family when he was only 12. His formal education may have been cut short but that didn’t stop his learning.  He began to experiment with electricity and learning at night, after work.  He became intrigued with wireless radio when he read how it was used to direct the ship Carpathia to rescue the Titanic passengers. He joined the Navy and managed to get ahold of textbooks to teach himself mathematics and science. After his service, he was hired at Raytheon, a newly formed company designing and manufacturing vacuum tubes.  Percy was particularly interested in producing radiation, specifically the use of magnetrons to generate signals used in radar.  That was something the US Government was keen to get for the war efforts.

One day in 1945, Percy showed up at work with a chocolate candy bar hidden in his pocket. While standing in front of the magnetron he was working on, he noticed the candy bar was melting.  He was fascinated by this behavior so he sent out for some unpopped popcorn and put it in front of the magnetron.  When it popped, he knew this small wave radar radiation could be used for cooking. He put the magnetron in a metal box and thus was born the first microwave oven.

Curiosity leads to discovery.  A disadvantage can often lead to a profound benefit.  What makes the difference?  In the case of Percy Spencer, his self-guided education taught him to ask why, to experiment and learn.  An unexpected occurrence, which by all rights could be viewed as an embarrassing disaster by many of us (melted chocolate pocket anyone?) turned into a critical discovery that has brought about an amazing benefit to humanity.  His creative idea was born out of curiosity, observation and action.

This year has been challenging for all of us. The new ways of working and the difficulties before us can be perplexing and discouraging at times.  But don’t give up.  Turn that melted chocolate bar into a discovery.  Ask, what can we learn from this crisis?  What experiment can we conduct to lead us on to discovery?   Are you limiting yourself or your thinking by the echo chamber we can easily find ourselves in?   Don’t.  Try something new this week.  Observe, ask why and then seek to answer it.  I suspect we are all sitting on a goldmine of new discoveries that we have yet to entertain.  Tap your opportunities and explore the unknown to see where it leads.

The next time you heat something up in the microwave remember how a melted candy bar and an inquisitive person handed us that useful invention.

Make a Difference

Aurora see in Wisconsin

“If you could only sense how important you are to the lives of those you meet; how important you can be to the people you may never even dream of. There is something of yourself that you leave at every meeting with another person.” ― Fred Rogers

Joan loved science.  When she was 8 years old, she declared to her family that she wanted to be a scientist.  Her mother scolded her, “Women’s brains can’t do science.”  She was crushed and went sobbing into a pillow, wondering if she had to let go of her dream.  On her 14th birthday her brother, Richard, gave her a college textbook titled “Astronomy” which included an impressive chart of scientific data produced by a female astrophysicist.  That was what she needed to encourage her to pursue her career. 

Joan earned her doctorate in physics in 1958 and went on to work at NASA and JPL where she made critical discoveries about the nature and cause of auroras, specifically the interaction of the Earth’s magnetosphere and the magnetic field of the solar wind.  She was recognized and awarded many honors for her contributions to astrophysics, sunspot cycles, environmental hazards to spaceships and climate change.  Before passing away this past July, Joan Feynman had pushed through the barriers of bad advice she had received as a child and went on to make a dent in the universe of human understanding, space travel and our world.  

We are often told what we can and cannot do.  Our families, others and our jobs can intentionally or unintentionally cast us into roles that limit our potential.  I think many of us can relate to bad advice that we have received from others or have given to ourselves.  There is a tendency for us to undervalue our significance or limit our own potential. We are surviving but are we thriving?  We turn the cogs of the machine, but are we living our potential?

You are important.  You make a difference.  The truth is that you individually bring a distinctive value to our human family.  Your individual contribution, diverse traits, history, strengths, challenges, specific talents and nuanced skills fit together into the unique puzzle that is us.  You belong.  Our teams, our organizations and our world would not be the same without you.  That is the incredible truth.  The collection of our uniqueness builds the fabric of who we are as individuals and as a group.  When someone leaves, we become less. 

What are you doing to challenge the barriers you or others have placed upon you?  What would you change?  Are you hiding any of your talents or distinctives that could make us better as a group?  Please don’t!  Bring you.  Make us all greater by being greater yourself.  Embrace the strengths and unique talents of yourself and others as part of our collective power.  Our gaps and our strengths combine to make a diverse spectrum of formidable capability that will help us, our companies and our human family become even greater.  

Each one of us has a unique opportunity to make a dent in the universe.  Encourage yourself.  Encourage others and leave a bit of yourself behind at every encounter.  Together, we become even greater. 

An Ocean of Science

“You must never confuse faith that you will prevail in the end—which you can never afford to lose—with the discipline to confront the most brutal facts of your current reality, whatever they might be.” – Admiral Jim Stockdale

It was hot in our valley this past week!  I built a simple outdoor weather station that displays current temperature, pressure and humidity.  This is the first time I saw it go above 114°F (45°C).  I was never so glad that I had planned time off and we had arranged for home healthcare to stay with my mother-in-law so that my wife, daughters and I could get away for a day.  Our big vacation was a trip down the 126 freeway to Ventura. 

Sometimes the simple things are best.  We parked at the beach, rolled down the windows and enjoyed the cool breeze.  We ate lunch in our van and watched the surf perform its dance across the shore.  It was like each wave was an ocean exhale reminding us that time keeps moving forward.  Its cool breath swept up the beach and gently across our faces.  It was serene and relaxing. 

As you can imagine, we were not the only ones to have this brilliant idea.  The streets and beaches were full of cars and people.  Sadly, most were not wearing masks or even attempting to social distance as they wandered about between the parking lots and beaches.  It struck me how difficult it has been for us to maintain vigilance in this area as we enter our 6th month of this pandemic.  I understand the frustration and know the desire to get back to normal, without face masks, distancing or shields.  There is a temptation to dismiss the science, minimize the seriousness or even justify rebellion against these safety measures.  Some of us figure that if we ignore it, it will just go away.  Unfortunately, that can only prolong and increase the impact.

We must never lose hope.  As the ocean reminds us that time marches on, so must we.  But that faithful determination must be coupled with discipline to confront reality.  As engineers, science is the illumination and tool of our profession.  We practice the scientific method to systematically experiment, learn and devise solutions.  Uncertainty, mystery and fear are chasms that we can bridge with methodical, step by step discovery and progress.  We can tunnel through difficult realities with cunning application of knowledge and persistence. The same can apply to this coronavirus pandemic and to the challenges in our businesses.  We can use our skills and expertise to help chart a solution forward.

Are we or others assuming or inventing a reality inconsistent with our scientific training?  Are there problems in front of us that could use a methodical approach to fully uncover and fix?  Do we set the example for others of being helpful, but logical, optimistic but scientific in our approach?  While 2020 has been an extremely challenging year, it is also a reminder that we have come a long way as a human family.  Behind us is an ocean of knowledge, discovery and tools that can amplify our ability to help those before us.  This week, I challenge you to tap that reservoir and heroically apply your talents to the problems at hand.  Strengthen your mind with hope and logic and let the winds of knowledge propel us forward.  And please, like other super heroes, wear a mask.  Stay scientific (and safe) out there!

Luminous Beings

Glowing Print

“Luminous beings are we.” – Yoda

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!

ATtiny85 Weather Station

Weather Station

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).

Circuit

Components:

  • ATiny85 Microcontroller (DigiKey)
  • BME-280 Sensor (Temperature, Pressure, Humidity) (Amazon)
  • 74HC595 8-bit Shift Register (Qty 4) (DigiKey)

Sensors

  • 7-Segment LED Display (Qty 4) (DigiKey)
  • 0.1uF Ceramic Capacitor (Qty 2)
  • 100uF Electrolytic Capacitor
  • 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).

Schematic

Circuit Board

ATtiny85 Microcontroller

Circuit Board

Programming Notes:

Code for this project is located on Github: https://github.com/jasonacox/ATtiny85-Weather-Station

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.

Solar Power Option

  • 1 x 2.5W 5V/500mAh Solar Cell – Amazon
  • 1 x 5V Micro USB 1A TP4056 Lithium Battery Charging Board with Protection Charger Module Amazon
  • 1 x 3.7V 3000mAh 755068 Battery Rechargeable Lithium Polymer ion Battery Pack – Amazon
  • 1 x 3.3V Linear Regulator 250MA MCP1700-3302E/TO – DigiKey

ATtiny85 Ultrasonic Distance Measurement for Parking Help

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.

List of Materials

  • 1 x ATiny85 Microcontroller (DigiKey)
  • 2 x 74HC595 8-bit Shift Register (DigiKey)
  • 1 x HC-SR04 Ultrasonic Distance Sensor (DigiKey)
  • 2 x 7-Segement LED Display CC (DigiKey)
  • 16 x 220 Ohm Resistor
  • 1 x 100uF Electrolytic Capacitor (DigiKey)
  • 1 x 0.1uF Ceramic Capactior – (Amazon)

Code

The code for the project can be found on GitHub: https://github.com/jasonacox/UltrasonicDistanceDisplay

Imperial and SI Units

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.

Prototype

Prototype Model without Box

ATtiny85 Arduino Programming with Sparkfun Tiny Programmer on a Mac

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.
  • Arduino IDE 1.8.12 (Download)
  • 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:

https://raw.githubusercontent.com/damellis/attiny/ide-1.6.x-boards-manager/package_damellis_attiny_index.json

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

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:

void setup() {
  pinMode(0, OUTPUT);
}

void loop() {
  digitalWrite(0, HIGH);   
  delay(1000);                       
  digitalWrite(0, LOW); 
  delay(1000); 
}

Click the upload button (right arrow) and 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