PaulS:
Create the functions in the ONE ino file.After loop(), put
/* Code to be sorted out *
/* */Move ALL the code in loop() to between those two lines.
Put ONLY the function calls I suggested in loop().
Add a new global variable to hold whatToDisplay.
Move the code that should set that variable into the determineWhatToDisplay() function, and set that variable.
Get that to compile, and print the variable whatToDisplay any time it changes. Even though the code won't actually accomplish anything, post that code, so that we can see that you recognized all the code that belongs in that function.
tried and i failed. I wanted to test it with only the photocell but I cant even get the code to compile.
#include <LiquidCrystal.h>
#include <IRremote.h>
#include <IRremoteInt.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
int RECV_PIN = 10; // The digital pin that the signal pin of the sensor is connected to
IRrecv receiver(RECV_PIN); // Create a new receiver object that would decode signals to key codes
decode_results results;
int photocellPin = A0;
int svjetlost;
int determineWhatToDisplay;
int whatToDisplay = 0;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
lcd.begin(16, 2);
receiver.enableIRIn();
}
void loop() {
// put your main code here, to run repeatedly:
determineWhatToDisplay(whatToDisplay=analogRead(photocellPin));
getDataToDisplay( lcd.setCursor(0, 0));
lcd.print("Svjetlost:");
lcd.print(whatToDisplay);
);
displayWhatNeedsToBeDisplayed( if (receiver.decode(&results)) {
if (results.value == 0xFF18E7){
return getDataToDisplay;
}
);
}
}
[code]
[/code]