Take the 2-minute tour ×
Arduino Stack Exchange is a question and answer site for developers of open-source hardware and software that is compatible with Arduino. It's 100% free, no registration required.

I am trying to control an Arduino Leonardo R3 to run some code when "triggered" from a Raspberry Pi, this would be in a loop so that it can be ran multiple times. I have setup the Raspberry Pi and tested it with an LED and the output is working fine.

I then connected this up to the Arduino and checked for a HIGH input from the RPi using an if statement.

void setup()
{
  pinMode(7,INPUT);


  if(digitalRead(7)==HIGH)
  {
  CODE IN HERE
  }
}

I found that this did not work as the if statement was always true because of pull up resistors not being used. I would greatly appreciate some guidance on this.

share|improve this question
1  
setup() runs only once, when the board is switched on (or reset). You should test pin 7 in loop() instead. –  jfpoilpret Dec 22 at 21:45
    
How do you connect the Arduino with RPi? –  jfpoilpret Dec 22 at 21:46
    
The reason I put it in setup first was because if I did something wrong didnt want it to continue constantly. I connected the GPIO from the RPi direct to the Arduino pin 7. –  Rahul Khosla Dec 22 at 22:16
1  
Be careful connecting the Raspberry Pi to the arduino directly. The 5V signals on the Arduino can damage the Raspberry Pi. –  Craig Dec 22 at 22:19
    
The Arduino is being used as an input, will this be OK? –  Rahul Khosla Dec 22 at 22:31

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.