[SOLVED] Simple Code to Read Inputs and Then Output a Signal

Hi Everyone!

I could use some help with a code for my Arduino Uno that will read a high signal from the GPIO output on my Raspberry Pi and then the Arduino will turn an LED on or flip a relay. I have tried for a few hours now to get this code working but I seem to be doing some thing incorrect. Has anyone tried doing this already where I could just see a sample of the code so that I know where to start? It would help me out a ton!

Thanks in Advance Max Kulik

Post your code and you will get help.

UKHeliBob: Post your code and you will get help.

This is the code that I have right now:

int in = 12; // Input pin
int out = 13; // Output pin

void setup() {
  pinMode(in, INPUT);
  pinMode(out, OUTPUT);
}

void loop() {
  if (digitalRead(in, HIGH)); 
  {
  digitalWrite(out, HIGH);
  } 
  else {
  digitalWrite(out, LOW);
  }
}

These are the errors that I am getting:

E:\Arduino\hardware\arduino\cores\arduino/Arduino.h: In function 'void loop()':
E:\Arduino\hardware\arduino\cores\arduino/Arduino.h:100: error: too many arguments to function 'int digitalRead(uint8_t)'
sketch_jul26a:10: error: at this point in file
sketch_jul26a:14: error: 'else' without a previous 'if'

digitalRead() only takes one argument, the number of the pin to read from. I assume what you meant to use isif (digitalRead(in) == HIGH))and the if line should not end with a semi colon

UKHeliBob: digitalRead() only takes one argument, the number of the pin to read from. I assume what you meant to use isif (digitalRead(in) == HIGH))and the if line should not end with a semi colon

I tried replaceing if (digitalRead(in, HIGH)); with if (digitalRead(in) == HIGH)) and this is what it gives me:

sketch_jul26a.ino: In function 'void loop()':
sketch_jul26a:10: error: expected primary-expression before ')' token
sketch_jul26a:10: error: expected `;' before ')' token

I figured it out. There was an extra ")" at the end of the line.

That was my fault. I could pretend that I put it there as an exercise for you to spot and fix the error.......

UKHeliBob:
That was my fault. I could pretend that I put it there as an exercise for you to spot and fix the error…

Well thanks! I am always eager to learn more and more about the Arduino!