Results 1 to 4 of 4

Thread: how to control Arduino pins Simultaneously?

  1. how to control Arduino pins Simultaneously?

    using functions how to compare the pins of arduino with the buffer(pointer) to an array or string? if the incoming data is matched to the user input pin it will execute the program in function example is arduino pin 2,3,4,5 High.
    Last edited by brian25; 08-12-2013 at 11:25 PM.

  2. #2

    Re: how to control Arduino pins Simultaneously?

    What's wrong with a simple if() statement?

    Where would the string come from?

  3. Re: how to control Arduino pins Simultaneously?

    how to pass the conditional statement in if() statement in array of arduino pins?

    tnx

    int PIN[] = {3,4,5};
    int LedCnt = 3;


    void setup()
    {

    for(int p=0; p<LedCnt; p++)
    {
    pinMode(PIN[p], OUTPUT); // Set the mode to OUTPUT
    }


    void loop()
    {
    LEDON();
    }



    void LEDON()
    {


    if (strncmp (smsbuffer, LED, 3) == 0)
    {
    Serial.println(smsbuffer);
    for(int p=0; p<LedCnt; p++)
    {

    digitalWrite(PIN[p], HIGH);
    delay(1000);
    Serial.println("ALL PINS ON");
    }
    }
    Last edited by brian25; 08-13-2013 at 02:55 AM.

  4. #4

    Re: how to control Arduino pins Simultaneously?

    I see -- you have an array of pin IDs, and you want to test whether all pins in that array are high.
    This needs a loop.

    Code:
    bool AreAllPinsOn(int const *pins, int count) {
      for (int ix = 0; ix != count; ++ix) {
        if (digitalRead(pins[ix]) != HIGH) {
          return false;
        }
      }
      return true;
    }
    
    ...
    int pins[] = { 5, 9, 13 };
    
      if (AreAllPinsOn(pins, 3)) {
        ...
      }

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Arduino bluetooth servo control
    By ArduTank in forum Mech Warfare
    Replies: 6
    Last Post: 07-08-2012, 03:26 PM
  2. Question(s) A Motor Controlled By Two Pins
    By Megasundato in forum Software and Programming
    Replies: 4
    Last Post: 08-31-2011, 12:39 PM
  3. Question(s) arbotix digital pins and board turning on and off
    By [email protected] in forum Software and Programming
    Replies: 4
    Last Post: 06-24-2010, 12:07 PM
  4. IO pins
    By Bevels in forum Arbotix, Microcontrollers, Arduino
    Replies: 8
    Last Post: 06-23-2009, 12:56 PM
  5. PVision library for Arduino (Pixart/Wiimote to Arduino)
    By shobley in forum Robot Computers
    Replies: 1
    Last Post: 03-01-2009, 05:07 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •