Hello,
I try to code using Serial.println a message on monitor, and using 2 buttons to activate 2 outputs of Arduino nano, but I got the errors. Could you please verify why it is ? Thanks.
On regular Nano code change "Dx" to "x" (for example "FAN_VAL = D4" >> "FAN_VAL = 4"... you will have more errors to correct... and you need to post those errors, too, but post them in a "code block". Your new errors will be from not defining variables in the right scope (defining inside a function restricts scope to that function).
Look more closely at just about any working example. You do not declare constants for pin numbers, for example, within the body of setup, because then they only exist there, and cannot be referenced elsewhere.
Again, please go look at, and mimic, the structure of simple examples.
Sometimes I feel like a human AI, the extent to which pattern matching and common sense underlie most of my success in this hobby. Maybe even in life itself.
There is nothing like a working example to answer questions definitively.
in the if condition you can omit "== 1" for checking if it is true. If you want to check a false state you can do it like this: if( !digitalRead(PIN) )
... just a tiny contribution from my side
actually I don´t see MPI declared neither as a variable nor as a Pin.
const int SW1 = A0; // Reserved. R9 installed, testing ONF_HEAT (sending +5V) when not connect to DPM
pinMode(SW1, INPUT_PULLUP);
because I can't get this pin = +5V (HIGH).
Thanks.
Okay, I have a question about this, too. The statement "const int SW1 = A0;" could generate an error of syntax because the symbol 'A' is not an int. How does the compiler treat this?
But yes, input pins with pushbuttons attached have to be pulled somehow.
It will be up,if you use the internal pull-up, and your button will make the pin LOW when it is pressed (normally open contacts).
You can use an external resistor to,pull either way. It is always advised to use pullup (resistor between 5 volts annd the input pin) and wire the contacts between the input pin and ground.