0

Read an input from Arduino
Moderators: adafruit_support_bill, adafruit

Forum rules
If you're posting code, please make sure your code does not include your Adafruit IO Active Key or WiFi network credentials.
Please be positive and constructive with your questions and comments.

Read an input from Arduino

by Arduinobrenn on Sat May 28, 2016 3:14 pm

Hi
I'm also struggling to do the following: I want to be able to send a High signal (3.3v) from an Arduino to the ESP8266 ESP-12E, and for the ESP8266 ESP-12E to publish it.
I can get the read a Low signal from ground as follows,
Code: Select all | TOGGLE FULL SIZE
pinMode(SENSOR1, INPUT_PULLUP);


Code: Select all | TOGGLE FULL SIZE
      current1 = digitalRead(SENSOR1);

  // return if the value hasn't changed
  if(current1 == last1)
    return;

  int32_t value1 = (current1 == LOW ? 1 : 0);

  // Now we can publish stuff!
  Serial.print(F("\nSending sensor1 value: "));
  Serial.print(value1);
  Serial.print("... ");

  if (! sensor1.publish(value1))
    Serial.println(F("Failed."));
  else
    Serial.println(F("Success!"));

  // save the button state
  last1 = current1;


How can I read a signal from my arduino?

Arduinobrenn
 
Posts: 7
Joined: Sat May 21, 2016 10:03 am

Re: Read an input from Arduino

by franklin97355 on Sat May 28, 2016 9:30 pm

How is the Arduino connected to the ESP8266? On what pin?

franklin97355
 
Posts: 21750
Joined: Mon Apr 21, 2008 2:33 pm
Location: Lacomb, OR.

Re: Read an input from Arduino

by Arduinobrenn on Sun May 29, 2016 2:50 am

It's not actually connected yet, I am just wanting to use one of the digital pins on the arduino as an output.
I was thinking I can pass it through a logical level shifter to drop from 5v to 3.3v.
Then set the pin as output high, when the alarm on the Arduino is triggered, to then switch to low.
Many thanks.

Arduinobrenn
 
Posts: 7
Joined: Sat May 21, 2016 10:03 am

Re: Read an input from Arduino

by franklin97355 on Sun May 29, 2016 3:13 am

That will work.

franklin97355
 
Posts: 21750
Joined: Mon Apr 21, 2008 2:33 pm
Location: Lacomb, OR.

Re: Read an input from Arduino

by Arduinobrenn on Sun May 29, 2016 3:54 am

Just one last question, do I need to edit the code from:- pinMode(SENSOR1, INPUT_PULLUP);
To just:- pinMode(SENSOR1, INPUT); ?

Do I need any pullup resistors or just straight in?

Thanks

Arduinobrenn
 
Posts: 7
Joined: Sat May 21, 2016 10:03 am

Re: Read an input from Arduino

by Arduinobrenn on Sun May 29, 2016 12:32 pm

SOLVED:

I have changed it to pinmode, Input and it works a treat.

Thanks for your help.

Now all I need is to find out how to read more than one button :(

Arduinobrenn
 
Posts: 7
Joined: Sat May 21, 2016 10:03 am

Please be positive and constructive with your questions and comments.