arduino ide add function

28 views
Skip to first unread message

Adam palecek

unread,
Mar 28, 2018, 12:36:24 PM3/28/18
to Developers

Hello,
I'm using arduino IDE and it occurred to me one thing you could add there. when you write: pinMode (8, OUTPUT); and then digitalWrite (8, HIGH); you can destroy arduino. so you can add a function to the IDE that would be on when it gets noticed?
Thank you

Billy

unread,
Mar 28, 2018, 12:53:34 PM3/28/18
to devel...@arduino.cc
Why do you say that's dangerous?
That looks like the usual way to set an output pin high.

--
You received this message because you are subscribed to the Google Groups "Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to developers+unsubscribe@arduino.cc.



--
ǝnɥɐuop ʎllıq

Adam palecek

unread,
Mar 28, 2018, 1:13:14 PM3/28/18
to devel...@arduino.cc
hello,
it was the error there should be: input

Dennis Lee Bieber

unread,
Mar 28, 2018, 1:16:58 PM3/28/18
to devel...@arduino.cc
On Wed, 28 Mar 2018 08:39:28 -0700 (PDT), Adam palecek
<pale...@gmail.com> declaimed the
following:
You'll have to expand on this concern...

"destroy arduino" HOW? I suppose if you have pin 8 physically jumpered
to ground, setting it to High could result in a massive current draw,
burning out the output driver for the pin. But by the same token, having it
jumpered to 5V and setting it Low could be just as dangerous -- so the
leads to...

"it gets noticed" -- WHAT gets noticed? Setting a pin mode to input or
output? Actually setting the value of a pin to High or Low (or either)? Any
use of the two operations in close proximity (what about if one has a
program using multiple files, and one file does all the initialization
while another file does the I/O -- is the IDE supposed to search for
correlations? After all, those two operations are EXPECTED to be performed
in order to toggle GPIO output pins.

What did you want the IDE to do? Pop up an annoying window saying
"Changing GPIO value could cause damage -- are you sure?" -- that wouldn't
get very far since changing GPIO value is the way an Arduino affects
outside actuators and displays, and requiring the programmer to acknowledge
every use of an expected/normal function call is not reasonable. I'd even
be annoyed by an IDE that flagged the call by using a red highlight color
on the statement.


--
Wulfraed Dennis Lee Bieber AF6VN
wlf...@ix.netcom.com HTTP://wlfraed.home.netcom.com/

Andrew Kroll

unread,
Mar 28, 2018, 1:17:47 PM3/28/18
to Arduino Developers
IIRC one of two things happens, depending on the order you do those two statements.

the way you just said to do it, will change the pin to output.
If you reverse the two statements, it is the same as doing INPUT_PULLUP


Visit my github for awesome Arduino code @ https://github.com/xxxajk

newc...@flounder.com

unread,
Mar 29, 2018, 5:37:43 AM3/29/18
to devel...@arduino.cc
Isn’t this exactly how you write a HIGH signal on pin 8? How can this
destroy the chip? And there is no reason to expect that these two
statements are in the same function, or even the same compilation unit.
For that matter, there is no guarantee that the first parameter is a ctce
(compile-time constant expression). For example, I might have three
identical devices, for the sake of this example, on pins 8,9 and 10, so
how would it even be possible to detect

in myprog.ino:

void setup()
{
for(byte i = 8; i <= 10; ++i)
pinMode(i, OUTPUT);
}

in device.cpp

void device::activate(byte pin)
{
digitalWrite(pin, HIGH):
}

The desired circuit is to set pins 4, 5, and 6 to INPUT_PULLUP, with a
pushbutton connected to GND, and have the following code (note that all
aspects of these examples are horrible examples of coding, but I would
write would be elegant and maintainable, but would make it even more
ridiculously impossible to do the detection. For example, I might start
with
struct {
byte signalpin;
byte activatorpin:
} pinmap[ ] = {
{ 4, 8 },
{ 5, 9 },
{ 6,10}
};

and all those numeric values in the above table would be named const byte
values. How I would use this is left as an Exercise For The Reader).

in myprog.ino:

void loop()
{
for(byte i = 4; i <= 6; ++i)
{
if(digitalRead(i) == LOW)
device::activate(i + 4);
else
device::deactivate(i + 4);
}

[Yes, I know I didn’t debounce the switch. Assume the switch is magically
debounced. The purpose of this example is to illustrate the absurdity of
checking for the problem. Which I don’t believe is a problem, unless
there is something weird about pin 8 that is not well-documented].
joe
> --
> You received this message because you are subscribed to the Google Groups
> "Developers" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to developers+...@arduino.cc.
>


Reply all
Reply to author
Forward
0 new messages