Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * ------Geiger Tube board (Arduino Code) Example--------
- *
- * Explanation: This example shows how to get the signal from the Geiger Tube
- * in Arduino, we use one of the Arduino interrupt pins (PIN2).
- * We count the time (ms) between two pulses of the Geiger tube.
- *
- * Copyright (C) 2011 Libelium Comunicaciones Distribuidas S.L.
- * http://www.libelium.com
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- * Version: 0.3
- * Design: Marcos Yarza, David Gascon
- * Implementation: Marcos Yarza
- */
- // Conversion factor - CPM to uSV/h
- #include <PString.h>
- #define CONV_FACTOR 0.00812
- // Variables
- //int ledArray [] = {10,11,12,13,9};
- int geiger_input = 2;
- long count = 0;
- long countPerMinute = 0;
- long timePrevious = 0;
- long timePreviousMeassure = 0;
- long time = 0;
- long countPrevious = 0;
- float radiationValue = 0.0;
- long radValue=0;
- char outString[50];
- PString transmission(outString,50);
- void setup(){
- pinMode(geiger_input, INPUT);
- digitalWrite(geiger_input,HIGH);
- Serial.begin(115200);
- attachInterrupt(0,countPulse,FALLING);
- }
- void loop(){
- if (millis()-timePreviousMeassure > 10000){
- detachInterrupt(0);
- countPerMinute = 6*count;
- radiationValue = countPerMinute * CONV_FACTOR;
- count = 0;
- transmission.begin();
- transmission += "$RDATA,";
- transmission += countPerMinute;
- transmission += ",cpm,";
- transmission += radiationValue;
- transmission += ",uSv/h~";
- /*tempMission ="$";
- tempMission += "cpm =";
- tempMission += countPerMinute,DEC;
- tempMission += " - ";
- tempMission += "uSv/h = ";
- radValue = radiationValue;
- tempMission += radValue,DEC;
- transmission = tempMission;*/
- timePreviousMeassure = millis();
- Serial.println(outString);
- attachInterrupt(0,countPulse,FALLING);
- }
- }
- void countPulse(){
- detachInterrupt(0);
- count++;
- while(digitalRead(2)==0){
- Serial.flush();
- }
- attachInterrupt(0,countPulse,FALLING);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement