9 digital inputs to control 16 digital outputs. inputs not working

Hello. I need read 9 digital inputs to control 16 digital outputs. My problem is when I conect the 3rd or 4th input to low, it makes the same as the first or second input. the outputs working well. In the code I did serial comands to test the outputs and they work, my problem is with the inputs. Can any one help please. thanks in advance, carlos

FrezeMarco.ino (14.7 KB)

without the wiruing it is a little hard to say, but i suspect that

pinMode(EntrataJoystickDietro, INPUT);
pinMode(EntrataJoystickAvanti, INPUT);
pinMode(EntrataJoystickDestra, INPUT);
pinMode(EntrataJoystickSinistra, INPUT);

you should define the pins as INPUT_PULLUP
Also really you should dive into using arrays for pin definitions so you can do the setting, reading & writing using a loop rather than what you do now.

   {
      Serial.println("Ricevuto Comando Freze Alsare");
      digitalWrite(30, LOW);
      digitalWrite(39, LOW);
      digitalWrite(45, LOW);
      digitalWrite(37, LOW);
      digitalWrite(41, LOW);

If you define constants for the pins, then you should use those.
If you redo your code like that, clean up all the white lines etc, you probably will be able to post it within </> code-tags and still stay below the 9000 chars.
I know it makes sense to name variables in your own language, but when you require support it can be a tad unpractical not to have them in English (here it’s still sort of ok, but i’d thought to mention it.)

Hello,

Also explain your problem clearly because I didn't understand :slight_smile:

Hello Edison and Faraday, I go clean a little bit the code, and I will post it again with all the issues I have. Thanks in advance, Carlos

Hi,
Welcome to the forum.

Please read the post at the start of any forum , entitled "How to use this Forum".
OR
http://forum.arduino.cc/index.php/topic,148850.0.html.
Then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

Thanks.. Tom.. :slight_smile:

Hello Mr Brattain

I tried clean the code as much as possible, but it is stiil too long to post as you instructed me between cotes. I anexed it.
I wiil make a diagram if necessary, but the digital pins 1 till 9 are inputs, and they are hardware conected to ground when I do the inputs. In the code, I have writed wich functions do not work, and that ones that work wrong. I certanly did some mistake because the serailprint is not working anymore. The comands that work fine , I have also writed hardware ok, and the failed ones, hardware error and type of error . I really apreciate the help of everybody because I cant see why some hardware inputs work, and others no. If I write the comands a untill n, all the outputs work correctly. Also in the end of the code, I did in a way that when all the inputs are HIGH, so no inputs, all the outputs should also go HIGH, because my relays also work with conection to the ground, but this do not work as well. Sorry for disturb you , but I cant undertand why this errors. Thanks in advance, Carlos

FrezeMarco.ino (12 KB)

Hi,

Forget your project code for the moment.

Make some code that JUST reads your inputs and displays the response in the IDE monitor.
What are your inputs, switches, buttons, sensors?

Make some code that tests the relay operation, such as cycles them and show on the IDE monitor, which relay is being operated.

A circuit diagram is essential at this point.

Thanks.. Tom.. :slight_smile:

Thanks for answer Mr Tom. I dont know why, but the serial monitir wont show me nothing. It seems that the serial printLn is not working.

Hello Mr Tom, Guix and Deva

Now it is working all fine. Just the serial println not print , but I want use it just to be printed that the arduino executed the operation, but as it is working now, I can leave it. In any case if someone can search why the serial println not work, I will apreciate offcourse. I post the working code. The inputs are pushbuttons, sometimes just one, sometimes a conbination of 2 and 3 pressed together. Best regards

Carlos

FrezeMarco.ino (11.8 KB)

As long as you don't use arrays for the pin assignments it is not really an improvement (other than the INPUT_PULLUP)
I don't see why the Serial.print() isn't working, do you have the same BAUD-rate in the monitor as you have in the sketch ? (9600)
Does the Serial input work at all ?

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.