chrisl provided a very good reference answer. Here I am just adding a
few bits of information about the pin mapping and the pin electrical
One of the firs things you need when dealing with direct port access is
the mapping between the Arduino pin names and the names of the
microcontroller (MCU) pins as given by the manufacturer. For the ...
digitalWrite() is just a convenience function to hide away complexity from the user, so that she/he can just use a pin number and a value. This complexity takes some time to execute. If this is too slow for you, you need to go a bit deeper into the rabbit hole and use direct port manipulation:
Inside the microcontroller on the Arduino all the special ...
All Teensies support digitalWriteFast out of the box. digitalWriteFast compiles to just setting the bit in the right port register. You can not do that faster by direct register manipulation.
However, if for some reason you do want to manipulate the registers directly here the pin/gpio relation for the T4. (Generated by the sketch described here: https://...
Some time ago, I timed digitalWrite() and direct port write commands by looping over 10,000 executions of each and timing them with millis(). I made both tests on a 16MHz Atmega 328p at 16MHz.
For digitalWrite(13, LOW), I got 2.7usec / call.
For PORTB &= 0x20;, I got 0.15usec / statement. (The direct port access was executed 10 times within the loop to ...
Setting ports directly is a great way to learn AVR programming. I might recommend this book Make: Avr Programming.
First you need to set the direction of the port in the Data Direction Register as either input or output. If Input, check its state and handle it. Here is a small example.
#define HIGH 1
#define LOW 0
#define SWI_PIN PORTB0
#define BUTTON ...
The setOutputPins() function sets the pins for a pulse for a single stepper. Depending on the used stepper motor a different number of pins has to be set (normal stepper drivers have 2 pins, the ULN2003 and its siblings have 4) in a different way. For that the function first determines the number of pins to use via the _interface member variable of the class....
Your sketch works on a Nano (clone) that I have
I am using a high-brightness white LED with a 10kΩ resistor to bring the brightness down to a bearable level, so the current drawn is about (5v-2.2v)/10kΩ = 0.28mA. This is a low level of current and should be safe for poking around with.
I can see the embedded LED blink if I program the Pin 13, but no impact ...
Never directly connect a motor to an Arduino IO pin
You will destroy the Arduino.
An Arduino cannot source (or sink in your case) enough current to drive a motor, and if the motor did manage to turn the huge amounts of EMI it generates would literally blast holes in the silicon inside the chip.
You must use a motor driver of some form. If you only want one ...
The esp8266 must have a pull-up on io 2 for boot configuration. The Wemos D1 boards put the LED in series with the pull-up resistor on io 2. This creates the 'reversed' LED behavior.
The large D1s are retired and it is hard to find a good and readable schematics. The cut out is from D1 mini schematics.
How can I set up outputs without using digitalWrite?
So this question is actually about the fastest possible implementation of digitalWrite.
As described in other answers this can be achieved by using direct port manipulation. But there are actually libraries (for instance, https://github.com/mikaelpatel/Arduino-GPIO) that does this in a portable way and ...
There are a number of issues here:
You state you have a 560kohm resistor, this is too high a value. With 5V it will restrict the current to 8.9uA.
This is too low to drive the LED, which probably requires up to 20mA (5V / 0.02A = 250Ohm at least)
This is also too low for for the base of the transistor (I'm not completely sure if my understanding of ...