i am trying to create a geiger counter logger so I can check the radiation levels in about a year's time however I want to log the data and at the same time still view my lcd display the thing is I'm almost there but the last bit won't quite work is there somebody out there who can help me the code is given below
// include the library code:
#include <Wire.h>
#include <SPI.h>
#include <SD.h> //is de sd kaart
#include <LiquidCrystal_I2C.h>
#define LOG_PERIOD 15000 //Logging period in milliseconds, recommended value 15000-60000.
#define MAX_PERIOD 60000 //Maximum logging period without modifying this sketch
#define PERIOD 60000.0 // (60 sec) one minute measure period
#define SD_CS 10
volatile unsigned long CNT; // variable for counting interrupts from dosimeter
unsigned long counts; //variable for GM Tube events
unsigned long cpm; //variable for CPM
unsigned int multiplier; //variable for calculation CPM in this sketch
unsigned long previousMillis; //variable for time measurement
unsigned long dispPeriod; // variable for measuring time
unsigned long CPM; // variable for measuring CPM
// initialize the library with the numbers of the interface pins
void meting(File &file);
LiquidCrystal_I2C lcd(0x27,16,2); // set the LCD address to 0x27 for a 16 chars and 2 line display
void setup() { // setup
Serial.begin(9600);
lcd.init();
lcd.init();
lcd.backlight();
CNT = 0;
CPM = 0;
dispPeriod = 0;
lcd.setCursor(0,0);
lcd.print(" Geiger Counter ");
delay(2000);
cleanDisplay();
attachInterrupt(0,GetEvent,FALLING); // Event on pin 2
while (!Serial);
Serial.print("Initializing SD card...");
if (!SD.begin(SD_CS))
{
Serial.println("SD card fail");
}
Serial.println("initialization done.");
}
void loop() {
lcd.setCursor(0,0); // print text and CNT on the LCD
lcd.print("CPM:");
lcd.setCursor(0,1);
lcd.print("CNT:");
lcd.setCursor(5,1);
lcd.print(CNT);
if (millis() >=dispPeriod + PERIOD) { // If one minute is over
cleanDisplay(); // Clear LCD
// Do something about accumulated CNT events....
lcd.setCursor(5, 0);
CPM = CNT;
lcd.print(CPM); //Display CPM
CNT = 0;
dispPeriod = millis();
}
}
void GetEvent(){ // Get Event from Device
CNT++;
}
void cleanDisplay (){ // Clear LCD routine
lcd.clear();
lcd.setCursor(0,0);
lcd.setCursor(0,0);
}
file = SD. open("FILEDATA.CSV", FILE_WRITE);
if(file)
{
file.print("CPM")
}
else{
Serial.println("file faild")
while(1);
}
void meting(File &file)
{
double CPM2 = bme.readCPM();
}
void printDataln(File &file, double data)
{
char number[12];
dtostrf (data, 6, 3, number);
file.println (number);
file.flush();
}