can i combine the gsm code with bluetooth code in one arduino?

GSM code
#include <SoftwareSerial.h>
char inchar; // Will hold the incoming character from the GSM shield
SoftwareSerial SIM900(7, 8);

int led1 = 10;
int led2 = 11;
int led3 = 12;
int led4 = 13;

void setup()
{
Serial.begin(19200);
// set up the digital pins to control
pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
pinMode(led3, OUTPUT);
pinMode(led4, OUTPUT);
digitalWrite(led1, LOW);
digitalWrite(led2, LOW);
digitalWrite(led3, LOW);
digitalWrite(led4, LOW);

// wake up the GSM shield
SIM900power();
SIM900.begin(19200);
delay(20000); // give time to log on to network.
SIM900.print(“AT+CMGF=1\r”); // set SMS mode to text
delay(100);
SIM900.print(“AT+CNMI=2,2,0,0,0\r”);
// blurt out contents of new SMS upon receipt to the GSM shield’s serial out
delay(100);
Serial.println(“Ready…”);
}

void SIM900power()
// software equivalent of pressing the GSM shield “power” button
{
digitalWrite(9, HIGH);
delay(1000);
digitalWrite(9, LOW);
delay(7000);
}

void loop()
{
//If a character comes in from the cellular module…
if(SIM900.available() >0)
{
inchar=SIM900.read();
if (inchar==’#’)
{
delay(10);

inchar=SIM900.read();
if (inchar==‘a’)
{
delay(10);
inchar=SIM900.read();
if (inchar==‘0’)
{
digitalWrite(led1, LOW);
}
else if (inchar==‘1’)
{
digitalWrite(led1, HIGH);
}
delay(10);
inchar=SIM900.read();
if (inchar==‘b’)
{
inchar=SIM900.read();
if (inchar==‘2’)
{
digitalWrite(led2, LOW);
}
else if (inchar==‘3’)
{
digitalWrite(led2, HIGH);
}
delay(10);
inchar=SIM900.read();
if (inchar==‘c’)
{
inchar=SIM900.read();
if (inchar==‘4’)
{
digitalWrite(led3, LOW);
}
else if (inchar==‘5’)
{
digitalWrite(led3, HIGH);
}
delay(10);
inchar=SIM900.read();
if (inchar==‘d’)
{
delay(10);
inchar=SIM900.read();
if (inchar==‘6’)
{
digitalWrite(led4, LOW);
}
else if (inchar==‘7’)
{
digitalWrite(led4, HIGH);
}
delay(10);
}
}
SIM900.println(“AT+CMGD=1,4”); // delete all SMS
}
}
}
}
}

Bluetooth code
#include <SoftwareSerial.h>
const int rxPin = 2; //SoftwareSerial RX pin, connect to JY-MCY TX pin
const int txPin = 4; //SoftwareSerial TX pin, connect to JY-MCU RX pin
// level shifting to 3.3 volts may be needed
SoftwareSerial mySerial(rxPin, txPin); // RX, TX
const int led1 = 10; // led pin
const int led2 = 11; // led pin
const int led3 = 12; // led pin
const int led4 = 13; // led pin
int state = 0; // if state is 1, the LED will turn on and
// if state is 0, the LED will turn off
int flag = 0; // a flag to prevent duplicate messages

void setup() {
// sets the pins as outputs:
pinMode(led1, OUTPUT);
mySerial.begin(9600);
digitalWrite(led1, LOW); // LED is initially off
pinMode(led2, OUTPUT);
mySerial.begin(9600);
digitalWrite(led2, LOW); // LED is initially off
pinMode(led3, OUTPUT);
mySerial.begin(9600);
digitalWrite(led3, LOW); // LED is initially off
pinMode(led4, OUTPUT);
mySerial.begin(9600);
digitalWrite(led4, LOW); // LED is initially off
}
void loop() {
//reads serial input and saves it in the state variable
if (mySerial.available() > 0){
state = mySerial.read();
flag=0; //clear the flag so we can print the state
}
// if the state is ‘0’ the LED will turn off
if (state == ‘2’) {
digitalWrite(led2, LOW);
if(flag == 0){
mySerial.println(“LED: off”);
flag = 1;
}
}
if (state == ‘0’) {
digitalWrite(led1, LOW);
if(flag == 0){
mySerial.println(“LED: off”);
flag = 1;
}
}
if (state == ‘4’) {
digitalWrite(led3, LOW);
if(flag == 0){
mySerial.println(“LED: off”);
flag = 1;
}
}
if (state == ‘6’) {
digitalWrite(led4, LOW);
if(flag == 0){
mySerial.println(“LED: off”);
flag = 1;
}
}
// if the state is ‘1’ the led will turn on
else if (state == ‘7’) {
digitalWrite(led4, HIGH);
if(flag == 0){
mySerial.println(“LED: on”);
flag = 1;
}
}
// if the state is ‘1’ the led will turn on
else if (state == ‘5’) {
digitalWrite(led3, HIGH);
if(flag == 0){
mySerial.println(“LED: on”);
flag = 1;
}
}
// if the state is ‘1’ the led will turn on
else if (state == ‘1’) {
digitalWrite(led1, HIGH);
if(flag == 0){
mySerial.println(“LED: on”);
flag = 1;
}
}

// if the state is ‘1’ the led will turn on
else if (state == ‘3’) {
digitalWrite(led2, HIGH);
if(flag == 0){
mySerial.println(“LED: on”);
flag = 1;
}
}
}

Running two instances of SoftwareSerial may not yield the results you want.

Please always remember to use code tags when posting code.

#include <SoftwareSerial.h> 
SoftwareSerial SIM900(7, 8);
SoftwareSerial mySerial(2, 4);
char inchar; // Will hold the incoming character from the GSM shield 
int led1 = 10;
int led2 = 11;
int led3 = 12;
int led4 = 13;
int state = 0; // if state is 1, the LED will turn on and,if state is 0, the LED will turn off
int flag = 0; // a flag to prevent duplicate messages
void SIM900power()
// software equivalent of pressing the GSM shield "power" button
{
  digitalWrite(9, HIGH);
  delay(1000);
  digitalWrite(9, LOW);
  delay(7000);
}
void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  //SIM900.begin(19200);
  // set up the digital pins to control
  pinMode(led1, OUTPUT);
  pinMode(led2, OUTPUT);
  pinMode(led3, OUTPUT);
  pinMode(led4, OUTPUT);
  digitalWrite(led1, LOW);
  digitalWrite(led2, LOW);
  digitalWrite(led3, LOW);
  digitalWrite(led4, LOW);

    // wake up the GSM shield
  SIM900power(); 
  SIM900.begin(19200);
  delay(20000);  // give time to log on to network.
  SIM900.print("AT+CMGF=1\r");  // set SMS mode to text
  delay(100);
  SIM900.print("AT+CNMI=2,2,0,0,0\r"); 
  // blurt out contents of new SMS upon receipt to the GSM shield's serial out
  delay(100);
  Serial.println("Ready...");
}

void loop() {
  // put your main code here, to run repeatedly:
//If a character comes in from the cellular module...
        if(SIM900.available() >0)
        {
          inchar=SIM900.read(); 
          if (inchar=='#')
          {
            delay(10);
       
            inchar=SIM900.read(); 
            if (inchar=='a')
            {
              delay(10);
              inchar=SIM900.read();
              if (inchar=='0')
              {
                digitalWrite(led1, LOW);
              } 
              else if (inchar=='1')
              {
                digitalWrite(led1, HIGH);
              }
              delay(10);
              inchar=SIM900.read(); 
              if (inchar=='b')
              {
                inchar=SIM900.read();
                if (inchar=='0')
                {
                  digitalWrite(led2, LOW);
                } 
                else if (inchar=='1')
                {
                  digitalWrite(led2, HIGH);
                }
                delay(10);
                inchar=SIM900.read(); 
                if (inchar=='c')
                {
                  inchar=SIM900.read();
                  if (inchar=='0')
                  {
                    digitalWrite(led3, LOW);
                  } 
                  else if (inchar=='1')
                  {
                    digitalWrite(led3, HIGH);
                  }
                  delay(10);
                  inchar=SIM900.read(); 
                  if (inchar=='d')
                  {
                    delay(10);
                    inchar=SIM900.read();
                    if (inchar=='0')
                    {
                      digitalWrite(led4, LOW);
                    } 
                    else if (inchar=='1')
                    {
                      digitalWrite(led4, HIGH);
                    }
                    delay(10);
                  }
                }
                
              }
            }
          }
        }
        if (mySerial.available() > 0)
        {
          state = mySerial.read();
          flag=0; //clear the flag so we can print the state
          if (state == '0') 
          {
                digitalWrite(led2, LOW);
                if(flag == 0){
                mySerial.println("LED: off");
                flag = 1;
                }
          }
          else if (state == '1') 
          {
                digitalWrite(led2, HIGH);
                if(flag == 0){
                mySerial.println("LED: on");
                flag = 1;
                } 
          }
          else if (state == '2') 
         {
                 digitalWrite(led1, LOW);
                 if(flag == 0){
                 mySerial.println("LED: off");
                 flag = 1;
                }
         }
         else if (state == '3') 
         {
                digitalWrite(led1, HIGH);
                if(flag == 0){
                mySerial.println("LED: on");
                flag = 1;
                }
          }
          else if (state == '4') 
          {
                digitalWrite(led3, LOW);
                if(flag == 0){
                mySerial.println("LED: off");
                flag = 1;
                }
          }
          else if (state == '5') 
          {
                digitalWrite(led3, HIGH);
                if(flag == 0){
                mySerial.println("LED: on");
                flag = 1;
                }
          }
          else if (state == '6') 
          {
                digitalWrite(led4, LOW);
                if(flag == 0){
                mySerial.println("LED: off");
                flag = 1;
                }
           }
           else if (state == '7')
           {
                digitalWrite(led4, HIGH);
                if(flag == 0){
                mySerial.println("LED: on");
                flag = 1;
                }
           }
          //over
       }
}

yup, i combined the code like this, but just the GSM code can run only, but bluetooth code cannot run

yup, i combined the code like this, but just the GSM code can run only, but bluetooth code cannot run

Only one instance of SoftwareSerial can listen at a time. That was the point that AWOL was expecting you to investigate (and get). Clearly, you didn't.

I’m also trying to combine GSM and BlueTooth just as the Original Poster.

I’m not sure if I should have started a new thread,

Here is a BlueTooth Sketch I striped to bare bones for simplisity.

The only 2 lines of code I added to the BlueTooth Sketch are

  • #include “SIM900.h”
  • if (gsm.begin(2400)) {}
#include "SIM900.h"
#include <SoftwareSerial.h>
SoftwareSerial mySerial(12, 13);
#define relay1 10
char val;
void setup() {
  pinMode(relay1, OUTPUT);
  digitalWrite(relay1, HIGH);
  mySerial.begin(9600);
  Serial.begin(9600);
  if (gsm.begin(2400)) {}
}
void loop() {
  //cek data serial from bluetooth android App
  if ( mySerial.available() > 0 ) {
    val = mySerial.read();
    Serial.println(val);
  }
  //Relay is on
  if ( val == '1' ) {
    digitalWrite(relay1, LOW);
  }

}

Line 11 which says

if (gsm.begin(2400)) {}

seems to be the problem.

If I comment out line 11, the bluetooth android app I’m using called “Arduino Bluetooth 4CH” from Google Play works as advertized
but, if I uncomment it back in, the relay does not turn on.

I could have added a bunch of serial.println to the BlueTooth code and used the Serial Monitor but I already know line 11 is the problem.

I have no idea how to trouble shoot this. I don’t have the source code to the Android App but I’m guessing even if I used a different app I would have the same problem.

What I do know is that the gsm.begin is a class belonging to this SIM900 Library <<click here

I have no idea what the conflict could be.

It’s driving me nuts.

Any Guidance would be great.

but, if I uncomment it back in, the relay does not turn on.

Perhaps it is as simple as your choice of pins. Try something other than 10, 11, 12, or 13, which are the SPI pins for the Uno and other 328-based Arduinos.

I tried all different pins. D4,D5,D6,D7,D8 A0,A1 etc.

Same result.

It works when gsm.begin is commented out.

I added some print lines.

#include "SIM900.h"

#include <SoftwareSerial.h>

SoftwareSerial mySerial(A4, A5);

#define relay1 10

char val;


void setup() {

  Serial.begin(9600);
  Serial.println ("Serial.begin(9600);");

  mySerial.begin(9600);
  Serial.println ("mySerial.begin(9600);");

  pinMode(relay1, OUTPUT);
  Serial.println ("pinMode(relay1, OUTPUT);");

  digitalWrite(relay1, HIGH);
  Serial.println ("digitalWrite(relay1, HIGH);");

//  if (gsm.begin(2400)) {
//    Serial.println ("(gsm.begin(2400)");

//  } // end if

}
void loop() {



  //cek data serial from bluetooth android App
  if ( mySerial.available() > 0 ) {
    Serial.println ("( mySerial.available() > 0 )");
    val = mySerial.read();
    Serial.print ("val is = ");
    Serial.println( val);

  }
  //Relay is on
  if ( val == '1' ) {
    Serial.println ("( val == '1' )");
    digitalWrite(relay1, LOW);
    Serial.println ("digitalWrite(relay1, LOW);");
    val = 0;
    Serial.println ("val set back to 0");
  }

}

Here are the 2 Serial Monitor Results.

The first one is the one that works with gsm.begin commented out:

Serial.begin(9600);
mySerial.begin(9600);
pinMode(relay1, OUTPUT);
digitalWrite(relay1, HIGH);
( mySerial.available() > 0 )
val is = 1
( val == '1' )
digitalWrite(relay1, LOW);
val set back to 0

And the second one that does “not work” that “does” have gsm.begin in it:

Serial.begin(9600);
mySerial.begin(9600);
pinMode(relay1, OUTPUT);
digitalWrite(relay1, HIGH);

ATT: OK
RIC: 
OK

DB:ELSE
ATT: OK
RIC: 
OK

DB:ELSE
ATT: OK
RIC: 
OK

DB:ELSE
ATT: OK
RIC: 
OK

DB:CORRECT BR
ATT: OK
RIC: 
OK

ATT: OK
RIC: 
OK

ATT: OK
RIC: ATE0

OK

ATT: OK
RIC: 
OK

ATT: OK
RIC: 
OK

ATT: OK
RIC: 
OK

ATT: OK
RIC: 
OK

ATT: +CPMS:
RIC: 
+CPMS: 0,30,0,30,0,30

OK

ATT: OK
RIC: 
OK

ATT: SHUT OK
RIC: 
SHUT OK

(gsm.begin(2400)

It Serial.println’s (gsm.begin(2400) but pressing buttons on the Android App does nothing when gsm.begin is part of the code.

I’ve tried looking thru the SIM900.cpp file but I’m not really skilled enough to know what I’m looking at.

The 3 workarounds I have thought of so far is:

  • Put it on the back burner and see if the solution comes to me when I’m not thinking about it
  • Use 2 seperate Arudino’s. One for GSM and one for BlueTooth and have them both share the relay board
  • Try other Android BlueTooth Apps to see if they share in the same gsm.begin problem

Any other thoughts, guidance, and trouble shooting advice?

Thank You Paul for all your help.

just guessing here, but the Arduino UNO has only 1 UART processor, so perhaps you can have only 1 serial device? Mega has 4 btw.

Soon i'll be trying the same and your solution may save me a ton of time

Can somebody please combine these two sketches for? I’ve tried it every way I could think of. I’d like to see how some body else would do it.

Sketch 01:

// Turn stuff on and off via SMS

#include "SIM900.h"
#include <SoftwareSerial.h>
#include "sms.h"
SMSGSM sms;

int numdata;
boolean started = false;
char smsbuffer[160];
char n[20];

void setup()
{
  //Serial connection.
  Serial.begin(9600);

  //Start configuration of shield with baudrate.
  //For http uses is raccomanded to use 4800 or slower.
  if (gsm.begin(2400)) {
    Serial.println("\nstatus=READY");
    started = true;
  } else Serial.println("\nstatus=IDLE");

};

void loop()
{
  if (started) {
    //Read if there are messages on SIM card and print them.
    if (gsm.readSMS(smsbuffer, 160, n, 20)) {
      if (strncmp(smsbuffer, "ON" ,  2) == 0) {
        Serial.println ("Do Something Cool via SMS");
        }
    }
    delay(1000);
  }
};

Sketch 02:

// Turn stuff on and off via BlueTooth

#include <SoftwareSerial.h>
SoftwareSerial mySerial(A4, A5); //Pin10 RX , Pin 11 TX connected to--> Bluetooth TX,RX

char val;
void setup() {

  mySerial.begin(9600);
  Serial.begin(9600);
}

void loop() {
  
  // check data serial from bluetooth android App
  if ( mySerial.available() > 0 ) {
    val = mySerial.read();

  }
  
  // Do Something Cool via BlueTooth.
  if ( val == '1' ) {
    Serial.println ("Do Something Cool via BlueTooth");
    val = 0;
  }


}

Each Sketch works separately but I don’t seem to be able to get them to work as one.

KrisKasprzak:
just guessing here, but the Arduino UNO has only 1 UART processor, so perhaps you can have only 1 serial device? Mega has 4 btw.

Soon i'll be trying the same and your solution may save me a ton of time

You can use the softserial library to "bit-bang" in software instead of using a UART.

Try this:

// Turn stuff on and off via SMS

#include "SIM900.h"
#include <SoftwareSerial.h>
#include "sms.h"
SMSGSM sms;
SoftwareSerial mySerial(A4, A5); //Pin10 RX , Pin 11 TX connected to--> Bluetooth TX,RX


int numdata;
boolean started = false;
char smsbuffer[160];
char n[20];
char val;

void setup()
{
  //Serial connections.
  Serial.begin(9600);
  mySerial.begin(9600);

  //Start configuration of shield with baudrate.
  //For http uses is raccomanded to use 4800 or slower.
  if (gsm.begin(2400)) {
    Serial.println("\nstatus=READY");
    started = true;
  } else Serial.println("\nstatus=IDLE");

}

void loop()
{
  ////////////////////////////////////////////////////////Bluetooth
  
  // check data serial from bluetooth android App
  if ( mySerial.available() > 0 )
  {
    val = mySerial.read();
  }

  // Do Something Cool via BlueTooth.
  if ( val == '1' )
  {
    Serial.println ("Do Something Cool via BlueTooth");
    val = 0;
  }

  ////////////////////////////////////////////////////////GSM

  if (started) {
    //Read if there are messages on SIM card and print them.
    if (gsm.readSMS(smsbuffer, 160, n, 20)) {
      if (strncmp(smsbuffer, "ON" ,  2) == 0) {
        Serial.println ("Do Something Cool via SMS");
      }
    }
  }
}
SoftwareSerial mySerial(A4, A5); //Pin10 RX , Pin 11 TX connected to--> Bluetooth TX,RX

You mean that you don't really have a mySerial attached to the pins? Then WTF is up with that stupid name? Why not use something meaningful, like, oh, I don't know, maybe bluetooth?

KrisKasprzak:
just guessing here, but the Arduino UNO has only 1 UART processor, so perhaps you can have only 1 serial device? Mega has 4 btw.

While using a Mega is probably a better answer, it is fairly practical have two serial devices on a Uno, one one hardware serial pins 0,1, and the other on software serial, for which you may use a variety of pins.

Keypel:
Can somebody please combine these two sketches for? I’ve tried it every way I could think of. I’d like to see how some body else would do it.

Sketch 01:

#include "SIM900.h"

#include <SoftwareSerial.h>

};




Sketch 02:


// Turn stuff on and off via BlueTooth

#include <SoftwareSerial.h>
SoftwareSerial mySerial(A4, A5); //Pin10 RX , Pin 11 TX connected to–> Bluetooth TX,RX




Each Sketch works separately

Then there is clearly nothing individually wrong with the codes, even if the comments don’t reflect what is really going on, but it is not a good idea to use two versions of Software serial, and that may be the cause of your problem. That said you probably don’t have a good reason for using the second one anyway, as your GSM shield should be configurable to use hardware serial.

Power_Broker:
Try this:

// Turn stuff on and off via SMS

#include “SIM900.h”
#include <SoftwareSerial.h>
#include “sms.h”
SMSGSM sms;
SoftwareSerial mySerial(A4, A5); //Pin10 RX , Pin 11 TX connected to–> Bluetooth TX,RX

int numdata;
boolean started = false;
char smsbuffer[160];
char n[20];
char val;

void setup()
{
 //Serial connections.
 Serial.begin(9600);
 mySerial.begin(9600);

//Start configuration of shield with baudrate.
 //For http uses is raccomanded to use 4800 or slower.
 if (gsm.begin(2400)) {
   Serial.println("\nstatus=READY");
   started = true;
 } else Serial.println("\nstatus=IDLE");

}

void loop()
{
 ////////////////////////////////////////////////////////Bluetooth
 
 // check data serial from bluetooth android App
 if ( mySerial.available() > 0 )
 {
   val = mySerial.read();
 }

// Do Something Cool via BlueTooth.
 if ( val == ‘1’ )
 {
   Serial.println (“Do Something Cool via BlueTooth”);
   val = 0;
 }

////////////////////////////////////////////////////////GSM

if (started) {
   //Read if there are messages on SIM card and print them.
   if (gsm.readSMS(smsbuffer, 160, n, 20)) {
     if (strncmp(smsbuffer, “ON” ,  2) == 0) {
       Serial.println (“Do Something Cool via SMS”);
     }
   }
 }
}

Thanks for trying Power Broker. It only works if I commit out if (gsm.begin(2400)) {

PaulS:

SoftwareSerial mySerial(A4, A5); //Pin10 RX , Pin 11 TX connected to--> Bluetooth TX,RX

You mean that you don’t really have a mySerial attached to the pins? Then WTF is up with that stupid name? Why not use something meaningful, like, oh, I don’t know, maybe bluetooth?

I wasn’t the author of the code. Yes, mySerial might not be the best descriptive name. lol

Nick_Pyner:
While using a Mega is probably a better answer, it is fairly practical have two serial devices on a Uno, one one hardware serial pins 0,1, and the other on software serial, for which you may use a variety of pins.

I have actually have a mega as well, for what ever reason my shield doesn’t fully turn on when using my mega. I’ll need to power my shield with an external power supply and try it again one of these days. I’d like to test this out to see if the mega solves the problem.

Nick_Pyner:
Then there is clearly nothing individually wrong with the codes, even if the comments don’t reflect what is really going on, but it is not a good idea to use two versions of Software serial, and that may be the cause of your problem. That said you probably don’t have a good reason for using the second one anyway, as your GSM shield should be configurable to use hardware serial.

My gsm shield is using hardware pins. I have the jumpers set to pins 3 and 4. I can change the pins in the library . I’m not sure why software serial is in the gsm sketch. It’s not being used. It still works if I comment out software serial from the gsm sketch. I think they just included it in the sketch if you end up using a software serial.

OK, Well… I just can’t get both the HC-05 bluetooth module and the gsm shield to play nice with each other.

I guess I’m going to use two different arduino’s.

one arduino for the gsm shield and the other arduino for the hc-05 bluetooth module.

But is it going to be a problem if both arduino’s are “sharing” a relay board?

both output pins on both arduino’s will be sending 5v output signals to the “single” relay board.

How do I keep one arduino from 5v signal safe from the other’s output pins?

I've given up trying to get both gsm and bluetooth to work on one arduino.

I'm just going to use two arduino's.?

But if the arduino on the left sends a 5v HIGH signal, how do I protect the arduino on the right from damage? (Or vice versa)

Or will 5V being unintentionally sent to the output pins of the other arduino not hurt it?

See Pic:

If both devices are standard Unos, they are both outputting 5V signals and expecting to read 5V signals on the inputs.
Be sure to connect the 2 Gnds together and power both up at the same time.

Keypel:
My gsm shield is using hardware pins. I have the jumpers set to pins 3 and 4.

Really?

OK, Well... I just can't get both the HC-05 bluetooth module and the gsm shield to play nice with each other.............I guess I'm going to use two different arduino's.

I guess, in the light of the first quote, that is a fair solution, but not one to talk about with your mates or your mother.

CrossRoads:
If both devices are standard Unos, they are both outputting 5V signals and expecting to read 5V signals on the inputs.
Be sure to connect the 2 Gnds together and power both up at the same time.

Thanks for the reply CrossRoads.

Both yellow wires are set to outputs in the picture below. If the arduino on the left sends a 5v HIGH signal to the relay, won't that same 5v HIGH also flow into the other yellow wire and go to the arduino on the right?

Is it OK for an arduino to receive a 5v signal to a pin that is set as OUTPUT? I just want to make sure before I destroy something.

I just want to make sure I'm understanding you correctly.

red wire = positive
black wire = ground
yellow wire = signal

.

Is it OK for an arduino to receive a 5v signal to a pin that is set as OUTPUT?

Read that question a couple of times. Does it even make sense? The Arduino receives signals on INPUT pins.