Menu

Not all ARDUINO UNO Pin work

Help
George
2017-12-17
2018-01-02
  • George

    George - 2017-12-17

    Hi dear,

    This is a test to see wich ARDUINO UNO pin should I use for input.
    I don't understand why only ARDUINO pin 2, 4 and 7 work correctly
    for input.

    When you say :
    cont int buttonPin = 3

    Pin3 doesn't work as an input. But Pin2 does

    Here's the code and the Circuit in attachment.
    Best Regards
    George

    const int buttonAPin = 3; //premier button RED
    const int buttonBPin = 4; //deuxieme button YELLOW
    const int buttonCPin = 5; //troisieme button GREEN

    const int ledAPin = 8;
    const int ledBPin = 9;
    const int ledCPin = 10;

    // Variable will change:
    int buttonAState = 0;
    int buttonBState = 0;
    int buttonCState = 0;

    void setup() {
    // Initialize the LED pinas an output:
    pinMode(ledAPin, OUTPUT);
    pinMode(ledBPin, OUTPUT);
    pinMode(ledCPin, OUTPUT);
    }

    void loop() {
    // put your main code here, to run repeatedly:
    buttonAState = digitalRead(buttonAPin);
    buttonBState = digitalRead(buttonBPin);
    buttonCState = digitalRead(buttonCPin);

    if (buttonAState == HIGH) {
    digitalWrite(ledAPin, HIGH);
    } else {
    digitalWrite(ledAPin, LOW);
    }
    if (buttonBState == HIGH) {
    digitalWrite(ledBPin, HIGH);
    } else {
    digitalWrite(ledBPin, LOW);
    }
    if (buttonCState == HIGH) {
    digitalWrite(ledCPin, HIGH);
    } else {
    digitalWrite(ledCPin, LOW);
    }
    }

     
  • Santiago

    Santiago - 2017-12-18

    Hi.

    I can't see the circuit in attachment.

    The problem is probably in the circuit because your code is working for me.

     
  • George

    George - 2017-12-18

    there it is:

    test_big_george

     
  • Santiago

    Santiago - 2017-12-19

    It is working for me.

    Do you have the simu file?

     
  • Santiago

    Santiago - 2017-12-21

    Hi.
    Report says everything is ok.

    what would be useful is the simu file.

    In any case is better to use "fixed Volt." components instead of switches.

    Regards.

     
  • Anonymous

    Anonymous - 2017-12-21

    Dear Santiago,

    The code needed to be change as I made some misteaks.
    It looks good but when the Switch 02 is on all Leds 10 11 12 13 are ON

    code:

    const int buttonAPin = 0;
    const int buttonBPin = 1;
    const int buttonCPin = 2;
    const int buttonDpin = 3;
    const int buttonEpin = 4;
    const int buttonFpin = 5;
    const int buttonGpin = 6;
    const int buttonHpin = 7;

    const int ledAPin = 8; // buttonApin 0
    const int ledBPin = 9; // buttonBpin 1
    const int ledCPin = 10; // buttonCpin 2
    const int ledDpin = 11; // buttonDpin 3
    const int ledEpin = 12; // buttonEpin 4
    const int ledFpin = 13; // buttonFpin 5

    // Variable will change:
    int buttonAState = 0;
    int buttonBState = 0;
    int buttonCState = 0;
    int buttonDState = 0;
    int buttonEState = 0;
    int buttonFState = 0;
    int buttonGState = 0;
    int buttonHState = 0;
    //
    void setup() {
    // Initialize the LED pinas an output:
    pinMode(ledAPin, OUTPUT);
    pinMode(ledBPin, OUTPUT);
    pinMode(ledCPin, OUTPUT);
    pinMode(ledDpin, OUTPUT);
    pinMode(ledEpin, OUTPUT);
    pinMode(ledFpin, OUTPUT);

    }
    void loop() {
    // put your main code here, to run repeatedly:
    buttonAState = digitalRead(buttonAPin);
    buttonBState = digitalRead(buttonBPin);
    buttonCState = digitalRead(buttonCPin);
    buttonDState = digitalRead(buttonCPin);
    buttonEState = digitalRead(buttonCPin);
    buttonFState = digitalRead(buttonCPin);
    buttonGState = digitalRead(buttonCPin);
    buttonHState = digitalRead(buttonCPin);

    if (buttonAState == HIGH) {
    digitalWrite(ledAPin, HIGH);
    } else {
    digitalWrite(ledAPin, LOW);
    }
    if (buttonBState == HIGH) {
    digitalWrite(ledBPin, HIGH);
    } else {
    digitalWrite(ledBPin, LOW);
    }
    if (buttonCState == HIGH) {
    digitalWrite(ledCPin, HIGH);
    } else {
    digitalWrite(ledCPin, LOW);
    }
    if (buttonDState == HIGH) {
    digitalWrite(ledDpin, HIGH);
    } else {
    digitalWrite(ledDpin, LOW);
    }
    if (buttonEState == HIGH) {
    digitalWrite(ledEpin, HIGH);
    } else {
    digitalWrite(ledEpin, LOW);
    }
    if (buttonFState == HIGH) {
    digitalWrite(ledFpin, HIGH);
    } else {
    digitalWrite(ledFpin, LOW);
    }
    }

    Kind Regards

     
  • Anonymous

    Anonymous - 2017-12-31

    Hello,

    Happy newyear Santiago