Please follow the advice given in the link below when posting code , use code tags when posting code here to make it easier to read and copy for examination
Please show a schematic of your hardware setup. I have a feeling that you're connecting your LEDs directly to the Dx pins without a current limiting resistor, relying on the microcontroller's protection circuitry to limit its source current. This would explain why you see the voltage that corresponds to the forward drop of your leds on the output pins.
Thanks for your response. I can confirm that I am connecting my LEDs in series with a 220 Ohm resistor. I have observed that my Blue LED causes the output voltage to be around 3V, whilst Red Green and yellow LED's are around 2.7V.
Simply swapping my Blue LED to a Red LED causes the output voltage to go from 3V to 2.7V.
Maybe this is what I should be learning.
I can confirm all switching (including remote) is working as expected. I am just curious as to the differing voltages for different LEDs.
My first suspicion was that the Nano 33 IoT board puts out different voltages on D7. I now know that is not true.
If I replace all LEDs with the same colour, I get the same voltages.
Do you measure the voltage directly at the pins (D5 etc.) or at the anode of the LED? Cause that would explain the different voltages.
Please note that the maximum source current of this microcontroller on any of its Dx output pins is either 2mA or 7mA depending on how you configure them. For instance for your red led and a 220R resistor, you're already trying to force 8mA through the corresponding pin, which the microcontroller won't allow. Please note as well it's bad practice to try and use the hardware protection of the microcontroller as a regular means of current limiting in your circuit.
Please refer to the SAMD21 datasheet, page 1010. https://ww1.microchip.com/downloads/en/DeviceDoc/SAM_D21_DA1_Family_DataSheet_DS40001882F.pdf
Ok thanks for this, I am still very new to this. I work with heavy electrics so loading etc are understandable. I followed an example from a web site which used an LED and a 220Ohm resistor as an example. I ramped up to four as per my circuit shown earlier.
So am I grossly overloading this board?
Obviously I am just experimenting, but if I did want an array of 4 LEDs in real life, what value resistors should I consider to allow me to not overload this board?
Did the example use this particular processor (SAM21) or e.g. an ATMega328? Note that the older ATmega328P allows a current draw of 20mA on a single output pin. Many simple led examples exploit this higher current sourcing capability. Personally I consider it bad practice to use microprocessor pins as power supplies, even if the loads are fairly low (e.g. ~5mA). Better use those pins to switch a (small signal) mosfet that in turn controls the leds or whatever other load you're switching.
Long story short: a microprocessor is not a power supply.
So according to Ohm's law, the current draw here is 0.9V / 220R = 4mA, which is either twice the permissible current draw or a little over half it, depending on how the pin is configured. I don't know how the Arduino IDE configures the SAM21 pins by default, whether they're run in high-current mode or not.
Yes, very much so, I suppose. Instead of trying to make a microprocessor do any heavy lifting, try to give it a lever. That's where stuff like transistors (MOSFET or BJT) and relays (/contactors) come in.
Use a LED calculator - either as a phone app, or online.
The better ones have presets for various kinds of LEDs, otherwise you have to check datasheets for the voltage drop of your specific LED (or measure it yourself).
So the point here is that the output drivers in the MCU have significant effective resistance. In the ATmega328 this amounts to something like 27 Ohms IIRC, but if the specification for this processor is a maximum of 8 mA, we may presume the effective resistance is at least 100 Ohms.
You will find charts in the datasheet showing how much the output voltage drops for various current draws, it is by no means insignificant.
blue LED in general is brighter and takes less current, try changing LEDs around and measure again, do you have similar situation but on different pin now?