keagle
March 19, 2016, 1:33am
1
My code is below, I have a wire going from TX to A2 on my arduino. All the output I get is 0’s even when the counter flashes up, what am I doing wrong?
//definitions
int analogPin= A2;
int Geiger= analogRead(analogPin);
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
Serial.println(Geiger);
delay(1000);
}
You only read once (during the declaration of the Geiger variable)
//definitions
int analogPin= A2;
int Geiger;
void setup()
{
Serial.begin(9600);
}
void loop()
{
Geiger = analogRead(analogPin);
Serial.println(Geiger);
delay(1000);
}
That will at least take care of the problem. As I don’t know how the Geiger counter works, I can not say if this does what needs to be done.
PS
please use code tags when posting code (or compiler error messages); if you quote my post, you can see how it is done
The default firmware of the Geiger counter outputs counts per minute on the serial line .