Questions tagged [digitalwrite]
Write a HIGH or a LOW value to a digital pin.
50 questions
2
votes
2
answers
863
views
How can I stop digital pins from floating at reboot?
I've got a LattePanda 3 Delta, which runs windows on its main processor and an Arduino sketch called StandardFirmata on its coprocessor. It's connected to a lock, which locks at HIGH and unlocks at ...
2
votes
2
answers
404
views
Can I use SPI-related pins as a Digital Output?
I am trying to use an esp32 (NodeMCU-32s) as a ringlight controller for my camera. All it should do is sense when an input pin goes low (the camera's output connects to ground when the shutter goes ...
0
votes
1
answer
471
views
LED doesn't completely turn off with digitalWrite(led, LOW);
When I was testing out a program I found a strange behavior of ESP8266.
LEDs don't turn off completely in the first digitalWrite(led, LOW), just the brightness of the LED goes down, but it does turn ...
1
vote
1
answer
187
views
Fast digital IO
I have a device programmable via an 8 bit digital parallel bus. I would like an Arduino to translate from a parallel 4 bit output of an existing device to 8 bit by intentionally reducing the ...
1
vote
2
answers
118
views
How to increase pinout switching?
Consider this code:
void loop() {
digitalWrite(pinTest, HIGH);
digitalWrite(pinTest, LOW);
}
On an Arduino Mega 2560, running 16MHz (=0.06us), I would expect the width of the pulse to be ...
0
votes
1
answer
215
views
How to control PWM and digital pins at the same time over ethernet in arduino
I am using Controllino Maxi. It has an Arduino Uno inside it. I am trying to control the PWM pin D0 and digital pin R0 via python code. Below is the code I have upload on arduino:
Arduino Code:
#...
0
votes
2
answers
464
views
Read Digital Input from Arduino Pin defined as OUTPUT
I'm working on a Home Automation Project.
I can turn on-off ESP32 pin from Alexa and Google Assistant Successfully now.
What I need help is with a way to read if the AC supply is ON/OFF on the Arduino ...
0
votes
1
answer
170
views
digitalWrite giving different output voltages between programs
I'm using an arduino uno R3 for lighting a few LEDs in response to coputer control. I've written two programs, the first to try an Object Oriented style, and the second to split up the code into more ...
2
votes
0
answers
204
views
Arduino Micro digital output pins floating / high Z
so i recently got an arduino micro for a project needing the control of two stepper motors with the A4988 driver. previously i was prototyping on an arduino uno and everything was working fine, but on ...
1
vote
2
answers
407
views
Why analogRead's value decreases when I decrease the value of resistor?(I use digitalWrite(high) to positive terminal of resistor)
Basically, my circuit contains only 1 resistor(like the basic LED circuit).
I tried to know what is the actual voltage of digitalWrite(High). I don't understand why the value of analogRead does not ...
0
votes
1
answer
3k
views
Random "Compilation error: Error: 13 INTERNAL: exit status 1". No clue how to resolve or even what causes this error
I am a beginner with Arduino. I have a program that is intentionally simple.
The code refuses to compile, spitting out the error Compilation error: Error: 13 INTERNAL: exit status 1. I have gotten ...
0
votes
1
answer
123
views
Check pin capabilities at compile time
Are there board-independent functions to check pin capabilities at compile time? I.e.
Can the pin be used as output, as in digitalWrite()?
Does the pin support PWM, as in analogWrite()?
Does the pin ...
1
vote
0
answers
150
views
Trouble with laser sensor
I have trouble with my laser sensor it doesn't work properly. When I connect all pins its doesn't work, when I remove GND and connect just the signal pin and VCC it works but the laser light is dim(I ...
2
votes
1
answer
443
views
analogRead() doesn't read more than 500Hz
I connected a wave generator to the analog pins to read the frequencies of the waves generated. I used different frequencies of sine waves with a minimum of 0V and maximum of 5V.
Whenever the voltage ...
-2
votes
1
answer
160
views
Use a simple LED with no digital pins to spare
Problem: I've made a circuit consisting of an 8x8 led matrix, which uses all of the digital pins on the Arduino UNO board, and I want to add an LED too it.
I tried looking around the internet but so ...
0
votes
2
answers
2k
views
Can I control solid state relay directly from arduino digital pin?
I want to switch on/off some AC device using solid state Omron G3MB relay
I know that for magnetic relay there should be transistor and flyback diode, but what about SSR?
Can I connect it directly to ...
1
vote
1
answer
2k
views
Onboard led HIGH and LOW seems reversed
On an ESP32 board I am trying this simple code to control the onboard led.
But if I set it to HIGH, led is OFF, if I set it to LOW, led is ON (fully bright).
What could cause this ?
The board has one ...
0
votes
1
answer
1k
views
analogWrite(PIN, 1023) <> digitalWrite(PIN, HIGH)
This question is very similar to this one.
I'm using an ESP8266 for which the maximum analogWrite value is 1023 rather than 255 for some other Arduino boards, but I believe the principal is just the ...
2
votes
0
answers
64
views
Very weird bug / odd behavior of OUTPUT
So, I have this code (Arduino Mega):
void setup()
{
pinMode(10, OUTPUT);
pinMode(11, OUTPUT);
pinMode(6, OUTPUT);
analogWrite(10, 50);
analogWrite(11, 50);
}
very basic motor speed control....
0
votes
2
answers
1k
views
digitalwrite() HIGH for arduino
How too know whether digitalwrite(HIGH, pin_number) sets the voltage to 5 volts or 3.3 volts. I am yet to purchase arduino uno. I want digital pin voltage to be 5 volts. I am aware that thereis a pin ...
0
votes
1
answer
214
views
digitalwrite with function parameter as parameter
Firstly, excuse my poor English, this is not my native langage.
I'm trying to use an Arduino Uno to drive an 8 relay board from an MQTT Subscription. I ask for help because i'm some kind of beginner ...
1
vote
1
answer
285
views
inconsistent digital output on simple code
so im new on arduino coding, and i made this code, where i input from serial monitor and then use it as a command for digital write. the problem is, sometimes the code work perfectly but then when i ...
1
vote
1
answer
235
views
else if is ignored if not Serial.println anything before
I encountered to me inexplicable behavior on an arduino uno.
I'm serial reading a string from the serial monitor/python serial. This string is the conditional on several if/else if statements.
The ...
0
votes
1
answer
615
views
AccelStepper library advanced codes!
I was trying to find out how this library can run multiple stepper motors at the same time, and I saw this important function called...
void AccelStepper::setOutputPins(uint8_t mask)
{
uint8_t ...
1
vote
1
answer
889
views
Nano: All digital pins do not output anything
New user here. Using the examples provided on the Arduino IDE software I could produce melodies with a piezo buzzer, or have a blinking LED.
Not anymore. No digital pin is giving anything. I can see ...
0
votes
1
answer
277
views
Digital Pin won't ground when set to LOW
My friend and I are repurposing an old rc car for a project. When we connect the dc motors to 5V and ground, the motors spin. However, when we power the motors from 5v and ground it in the digital ...
1
vote
0
answers
103
views
How to write analog signals to control throttle of the ship?
I am using teensy 2.0 as DAC. I am trying to write signals on rudder and throttle of the ship via relay. How can I write these analog signals? Should I specify voltage for every pin?
Here is my code:
...
0
votes
4
answers
2k
views
Is it dangerous to connect two output pins together?
If I have two output pins, one set high and the other set low with digital or analog write like this
digitalWrite(PIN1, LOW);
digtialWrite(PIN2, HIGH);
and then I short them together using a wire, ...
2
votes
1
answer
1k
views
ESP 8266 reverse digitalWrite behaviour on which pins?
I am using a device with an ESP 8266 microcontroller. I have discovered that setting LED_BUILTIN to HIGH turns the built-in LED off and setting LED_BUILTIN to LOW turns the built-in LED on. This ...
4
votes
4
answers
3k
views
How can I set up outputs without using digitalWrite?
Consider the following:
#define IN1 9
#define IN2 10
pinMode(IN1, OUTPUT);
pinMode(IN2, OUTPUT);
void LeftMotor(Direction direction) {
digitalWrite(IN1, direction == Forward ? LOW : HIGH);
...
1
vote
1
answer
2k
views
What is the equivilent of PORTx for Teensy (4.0)?
I've seen people use code like PORTB |= 0x1 << 6 to set the sixth bit of PORTB in arduino. I understand that this is significantly faster than using digitalWrite. How can this be done using a ...
-1
votes
1
answer
550
views
Is the shiftOut code depending on the (low) speed of an Arduino?
In the (official) file wiring_shift.c I found the following code for shiftOut:
void shiftOut(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, uint8_t val)
{
uint8_t i;
for (i = 0; i < ...
-1
votes
1
answer
1k
views
Attiny85 simple analog and digital output problem
I'm just lighting up an LED through a TIP31C, pin 0 goes through a 560kohm resistor to the tip's input pin
pin 1 goes through a 750 ohm resistor to the tip's input pin
^i'm not sure this information ...
2
votes
1
answer
1k
views
Ardunio Mega/ATmega2560: Using Port F or K for both analog inputs and digital outputs
On an ATmega2560, can ports have some pins used for analog inputs but others as digtial i/o? Specifically, I only need to use 3-5 analog inputs but have many digital inputs. I would like to use the ...
0
votes
1
answer
375
views
Replicate output of pwm pin on another output pin?
Ardiuno Mega 2560
I have a legacy PCB that connects PORTA, pins = {22, 23, 24, 25, 26, 27, 28, 29} to the PWM input of a set of actuators. The accompanying code made use of an interupt service ...
0
votes
2
answers
7k
views
Using NodeMCU D8 (GPIO15), D4 (GPIO2) and D3 (GPIO0) pins
I am using a NodeMCU board and have already used 6 digital pins as output for interfacing with the LCD. I intend to use 2 more digital pins, one as input and other as output for interfacing an ...
0
votes
0
answers
96
views
digitalWrite on Trace SWO pin
I'm using STM32(generic board) and I want to control bi-color LED(common anode). STM32 pin layout and scheme is below, so please see it.
Now, in theory scheme Works, but in practice it Works halfway. ...
3
votes
3
answers
8k
views
How to initialize digital output pin as low
I need to define a pin as output for relay module but when i do it in setup section, relay is activated (low - 0) automatically then i deactivated immediately with coding digitalWrite(pin, 1) but this ...
0
votes
2
answers
652
views
Replace digitalWrite with a selective bitwise operation
I have the following code with digitalWrite I aim to write with bitwise operation only.
No portability concerns here whatsoever. (for atmega328p here)
#define DATAOUT 11//MOSI
byte commandbits = ...
1
vote
1
answer
367
views
Does direct port access interfere with PWM?
I think I've scoured the SE for questions about PWM, and fast digitalWrite etc, but I didn't see this point addressed.
I need to use direct writes to some digital pins. Some of the pins on the port ...
0
votes
2
answers
5k
views
Sending a digital signal from one Arduino to another to trigger an event
I am wanting to send a digital signal from one Arduino to another. The goal is for one Arduino send a HIGH signal to a pin on the receiving Arduino. While the pin is HIGH, do function
I initially ...
0
votes
1
answer
2k
views
setting output analog/digital pin to ground
So I need to automaically eject a CD from a Blu-Ray drive, I have a wire welded on the drive's card that if manually connected for a split second (pulse) to the ground of that same card on the drive, ...
0
votes
1
answer
102
views
A minor confusion in digitalWrite command
Will the Arduino IDE interpret digitalWrite(13,x), where x>0, as digitalWrite(13,HIGH)?
And will it interpret digitalWrite(13,x), where x<=0, as digitalWrite(13,LOW)?
1
vote
1
answer
1k
views
Analog pins as output by using digitalWrite
I am making a triac-controlled light dimmer. To control the triac I want to use pins A4 or A5, because others are occupied. I have tried the following functions and methods, but nothing seems to put ...
1
vote
1
answer
5k
views
Arduino digitalWrite not working
I am trying to control this OWI Robotic Arm using the Arduino's digital outputs (I am using pins 12 & 13).
If I wire up the wires to ground and 5V it goes one way, if I switch the wires, it goes ...
1
vote
2
answers
702
views
DigitalWrite Cannot Power HC-06 Bluetooth
To save power consumption, I tried to connect the HC-06 bluetooth module to a digital pin of my Arduino Nano. (HC-06 +5V <=> pin 11, HC-06 gnd <=> gnd) In that way, I can toggle the bluetooth ...
5
votes
5
answers
2k
views
Is it possible to make normal pins act like ground pins?
So what exactly I am trying to do is control a motor and be able to turn it both ways without any extra parts.
So if the hmp was on (the plus pole) and the hmm (the minus pole) acted like ground the ...
0
votes
1
answer
170
views
Broken Loop and dim LEDs
I want to make 2 LEDs blink back and forth continuously, but they only do so once, and the second one is very dim.
code:
int ledone = 12;
int ledtwo = 10;
int keepgoing = 1;
void setup() {
pinMode(...
2
votes
1
answer
6k
views
Is the DigitalWriteFast library still needed?
Yesterday I played with a SRAM 621024 SRAM 1 Mbit IC and since I use a lot of pins, digitalReads and digitalWrites are needed including shift registers (see Example
Since it took a long time for ...
-1
votes
1
answer
887
views
The function AnalogWrite is outputting less voltage than digitalWrite on my board
I can't figure out why the output voltage of analogWrite(255) is less than the voltage of digitalWrite(255). My code and an image of my setup are below. Some other useful information is that I am ...