Please let me know if you experience any problems with this code. Be sure to check back for more Arduino code.
Schematic:
Code:
/*
Oliver Holden
Created 28/10/2014
Components:
* Arduino UNO
* LDR
* 10K resistor
- Gets an analogue value of Light from an LDR
Prints the data to the Serial Monitor
Data is sent to an Excel spreadsheet through data
acquisition software, PLX-DAQ, Download http://www.parallax.com/downloads/plx-daq
Schematic for this project is on
http://breadboarder.blogspot.co.uk/
*/
int LDRPin= A2; // LDR Reading Pin
int LDRReading = analogRead(LDRPin); // Reading analogue value from LDR
int x = 0; // For PLX-DAQ
int row = 0; // For PLX-DAQ
void setup()
{
Serial.begin(9600); // Opening serial connection at 9600bps
Serial.println("Light"); //Printing Serial Monitor header
Serial.println("LABEL, Time, LDR"); // Setting headers of colums in PLX-DAQ spreadsheet
Serial.println("\n-----------------");
}
void loop() {
Serial.println(LDRReading); // Printing data to Serial Monitor
row++; // For PLX-DAQ
x++; // For PLX-DAQ
delay(1000); // Printing data once a second
}
It's there to separate the headings from the data so it prints like this:
ReplyDeleteLDR
-----------
Value
I think that's why.
Thanks for letting me know while since I have used it, Im not to sure why it wouldn't work though as I tested all of my code before I posted them have you got it working with that your code?
ReplyDelete