Question about a program I found

Dear all,

I have a little trouble understanding a part of a program someone on my workplace wrote that I have to use now. She uses this code:

i=(int)(rate);

I have no idea why the (int) is there, what does it do? In the beginning of the program she already defined:

int i = 0;

Can anyone of you help me?

Thanks in advance!

Hi,
What is the program supposed to do, and was it written in C++.
What controller/computer is it supposed to run on?

A piece of code is not enough, we need it all if it is a sketch for an arduino controller.

Tom... :slight_smile:

Ah, ok:) It is supposed to run on an arduino UNO. It is a program that detects radioactivity in counts. I added the program i found in the attachements.

I have no idea why the (int) is there, what does it do?

The (int) is a cast. It forces the value on the right to be interpreted as in int, regardless of what type it actually is. It probably does not need to be there. If i and rate are the same type, the cast is silly. If they are not, an implicit cast will be performed IF NEEDED (which it probably isn't).

Ah, ok thanks!

Another thing that I can't seem to find in the code is the pin where the sensor is read. Shouldn't there be a command like:

pinMode(2,INPUT);

Shouldn't there be a command like:

Yes, but pins are INPUT by default, so the pinMode() call could (not should) be omitted.

Didn't know that:) but then where in the code is the value of the input read? In the papers that I found with it, it said that the input signal should be on pin 2, but I can't find in the code that that value is read.

but I can't find in the code that that value is read.

I can't either, from pictures of the code. Code should be posted as text. If the idiot left you nothing but pictures or printouts, you should track her down and kick her ass.

Well, the idiot did indeed left me only this. No other data to be found sadly enough. So I'm trying to figure out as much as possible from the code, but I'm not even 100% sure that this is the code on the arduino. I'm going to rewrite it, and put some more information in it for the people after me.

Hi,

Can you please post a copy of your sketch, using code tags?
They are made with the </> icon in the reply Menu.
See section 7 http://forum.arduino.cc/index.php/topic,148850.0.html

This will put you code in a scrolling window that will be easier to read.

Tom.... :slight_smile: