8. Electronics Design - Collin Kanofsky,¶
Analog vs Digital Pins¶
A digital IO pin is a pin that can only be designated as high/low or on/off, we have used digital pins to make an LED turn off and on but no in between. An Analog IO pin is a continious signal that differentiates in magnitude. This allows you to make an LED dim or read real world data. This is a reference that I found off of a electronic circuit course by Tony Kuphaldt.
Testing PWM with a Multimeter¶
We first tested our PCB boards with a multimeter finding the voltage of the LED that is controlled by the ATtiny412. We wrote a code that works of a PWM IO pin off the ATtiny412 which is a digital pin that is able to mimic an Analog one by manipulating the time the pin is powered for giving it the allusion of a lower or higher voltage. This is the code we wrote for an LED to dim off an ATtiny412. Since we wrote it off a PWM pin (which is indicated by a ~ next to the pin on pinouts), you can code it as if you are coding an analog pin and it will work similarly.
When we use the voltage setting on the multimeter and hold the negative probe at ground and the positve probe on a positive end and we get a the voltage we got a voltage of 2.175. When we put the probes on the LED again, we got a voltage of .622. The voltage read here is a reading of the mean voltage that is read when the power is turned on and off at specific intervals. For a better look, we need to use an oscilloscope.
Testing PWM with an oscilloscope¶
An oscilloscope is an electronical testing instrument that visually displays voltage over time. This is different to a multimeter because the multimeter can only give the voltage of a certain moment in time while the oscilloscope can show you how your voltage is changing. When we turn on our Siglent SDS1202X-E and put the probes the same way we did with the multimeter.
When the LED is being powered, it is when the line is higher up. When it is off, it is flat on the lower half. As you can observe, the dimming LED’s time that it is powered is exponentially getting smaller or larger depending on either if they are getting dimmer or brighter. The PWM pin is able to manipulate this time to imitate the ranging ‘states’ that an analog pin is able to exhibit.
Downloads¶
You can download the code we used to dim the LED here