Re: function is not being called

pinMode(A1, INPUT);

I suspect this is your problem. I don’t think you are supposed to use pinMode() with the analog pins. This function call takes arduino pin 1, which is the serial transmit data line, and makes it an input, so you won’t get output from the serial port afterwards.

Take out that function call and see if it works better.

-j

"if(calcount = 0)" doesn't mean that you are checking if calcount and 0 is the same number. It will apply the number 0 to calcount. And as far as i know that makes the statement false because calcount then is zero and thus false.

What you should do however is this:

if(calcount == 0)

This will check if calcount is zero, which is what you want to do.

/Have a great day, Fredrik Andersson

Yes i finally realised that last nite after i posted the comment…forgot the second “=”…i took out the funstion call and it worked :slight_smile:

and j, as for pinMode() with the analog pins.
I dont quite understand what you are saying about arduino pin 1. If i want to take in an analog sensor values then how exactly can i read it in without using INPUT for the analog pins??? I use serial.print to print out the values of A0-A4. Is this not the right way??

The analog inputs are inputs by default, you don't need to call pinMode() on them. In fact, when you call pinMode(A1, INPUT), you're actually setting digital pin 1 to be an input.

ah i see now! well code is working, thanks for replying