With a Arduino Mega, I want to send a "1" to digital output, say D4.
The "D" will be static. But the port number needs to change.
For example I will have a loop where I increase the integer value of PIN,and send 0 or 1 in a digital write.
In the following statement, for a digital output, the variable "PIN" is an integer.
DigitalOutput = STRING ('D' + PIN) FC is ok with the ststement, but it prints "69"
Any help is paareciated.
Creating a string to be used in a digital output statement
-
Billduck1302
- Posts: 35
- http://meble-kuchenne.info.pl
- Joined: Fri Dec 06, 2024 4:41 pm
- Has thanked: 2 times
- Been thanked: 1 time
-
mnfisher
- Valued Contributor
- Posts: 1882
- Joined: Wed Dec 09, 2020 9:37 pm
- Has thanked: 154 times
- Been thanked: 887 times
Re: Creating a string to be used in a digital output statement
The easiest way to do this is with a little C.
For example for port d (assuming the pin is set as an output)
PORTD |= (1 << FCL_PIN);
Will turn on 'pin' without affecting other pins in port d
Martin
For example for port d (assuming the pin is set as an output)
PORTD |= (1 << FCL_PIN);
Will turn on 'pin' without affecting other pins in port d
Martin