Biomechanist:
Pin 15 = "VIN"
Pin 2 = "3V"
That's much more clear now. When we talk about pin numbers here, we mean the Arduino pin numbers that you use in your sketch. Arduino pins 15 and pin 2 are very different things from the VIN and 3V pins.
Biomechanist:
Either of the previous two sketches I posted show exactly what I am doing with the code.
I agree. You've done a good job at providing minimal demonstration sketches. That is very helpful. What was not clear to me is what your exact measurement procedure is. That's why I asked for clarification.
Biomechanist:
I don't have a scope.
Understandable. I only recently got one and it's the cheapest of the cheap. There are other tools that are a higher priority to acquire than an oscilloscope and I know that many of us only have a limited budget to spend on our hobby. In a case like this where you have a pin outputting a frequency, it's difficult to understand what is happening without an oscilloscope. Your multimeter can't measure these fast voltage changes. You should see some voltage on the pin (e.g., the 2 V I measured), but that doesn't tell you what is really happening. In this case, a logic analyzer would also be usable. You can get the cheap Chinese clones of the Saleae 8 for around $7 from the usual places and I think that's a pretty useful tool to have, even after you get an oscilloscope.
Biomechanist:
I am new to working with Arduino. I am not sure what official terminology is or not.
I understand. It's a common problem we deal with here. Now you know, so you can communicate more effectively here in the future.
Biomechanist:
I found this pinout on the Arduino site and have been referencing it for pin numbers
Yeah, I really don't like that table. I would have left off the first column, as it doesn't give any useful information and only leads to confusion. Nobody here uses the physical pin numbers.
Biomechanist:
as was already discussed there are no constant values defined for the digital pins.
Yeah, but that's not a problem. If you want to reference digital pin 1, you use the number 1, and so on. When it comes to the analog pins, use the A0, etc, pin names, even when you are using them as digital pins.
Biomechanist:
How is it that I am the first person to report this?
Well, for one thing, the Nano 33 BLE boards are Arduino's newest product so, compared to the other boards, not as many people are using them and they haven't been using them very long. But the more significant reason is that it's unusual to write code that writes the pin HIGH over and over again. Once the pin is HIGH, there is no need to waste clock cycles setting it HIGH again. More typically, we are setting the pin HIGH, then LOW, then HIGH, etc. In that case you wouldn't notice a problem because you are trying for a square wave anyway.
Biomechanist:
I don't believe analogWrite is behaving correctly on these pins either.
Are you referring to the problem you reported in your first post? I can reproduce that issue. I don't know the cause though. I can add that the debug output the Nano 33 BLE prints on the TX pin at 115200 after you upload the sketch is:
++ MbedOS Error Info ++
Error Status: 0x80FF0144 Code: 324 Module: 255
Error Message: Assertion failed: result == NRFX_SUCCESS
Location: 0x1593D
File: ./mbed-os/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF52/pwmout_api.c+109
Error Value: 0x0
Current Thread: main Id: 0x20001834 Entry: 0x1687D StackSize: 0x8000 StackMem: 0x200025E0 SP: 0x2000A524
For more info, visit: https://mbed.com/s/error?error=0x80FF0144&tgt=ARDUINO_NANO33BLE
-- MbedOS Error Info --
Although Arduino has been able to hide it from the user to some extent, the Nano 33 BLE boards use an advanced RTOS (Mbed OS) that does impose some additional constraints on what you can do. There is some conflict between that analogWrite() code you wrote and Mbed OS.
Biomechanist:
It seems like a major design flaw to have something as simple as setting a pin high or low not behave as expected (!)
I agree it's unfortunate. The Nano 33 BLE boards use a very different microcontroller and software framework from any of the other official Arduino boards. This means a lot of work to get everything working just right. I'm sure we will see steady improvement as time goes on.
Biomechanist:
This is also very off-putting for someone such as myself who is new to working with Arduino hardware. Is this typical of their products?
It's typical that the support software for the newer hardware will be more likely to have bugs. Over time, the bugs are reported and then fixed. You are much less likely to encounter bugs when using the classic AVR boards (e.g., Nano, Uno, Mega, Leonardo). You will also find there is better community support for these boards (e.g., libraries, example sketches, tutorials) simply because they have had years longer to accumulate these resources. For this reason, I would recommend that beginners start with the AVR boards. If you really do need the greater resources and features of the new boards, then that's just how it is, but for the simple learning projects, and even some quite demanding advanced projects, the AVR boards are plenty capable. I think of the newer boards as more appropriate for people who are adventurous and interested in the opportunity to participate in the testing and development process.
Biomechanist:
To have a dozen useless pins on a board that's approaching ~ $40 seems totally unreasonable.
I'm not yet convinced that the pins are useless. I'll wait to hear back from you regarding the pin numbers before I can say more. So far, from my own tests, all I've seen is:
- The issue with your analogWrite sketch crashing, which I suspect is more a matter of needing to learn how to work with Mbed OS.
- The issue of a square wave being generated when you set the pin HIGH over and over again, which can easily be avoided by simply writing your code so that doesn't happen.
Biomechanist:
Well, thank you for the help thus far and Happy New Year to all, and I really hope this is resolved by the time early 2020 rolls around!
Happy New Year to you as well! We're here to help you out with this and I think we can make some progress if we stay positive and keep working at it.