Will this basic code work?

acm01:
Thanks for the feedback!
I tried running the verify option and I got back "Binary sketch size: 1830 bytes (of a 32256 byte maximum)" I've no idea what that means and that's why I came here! :smiley:

That means it compiled successfully without errors, congratulations. Again it doesn't mean there might not be a flaw in the sketch, only running it and observing the output results will tell you that.

So I've gotten a bit mixed up, should I be writing 2000 or int? There needs to be a 2 second limit so I thought you needed to put that top value in?

You did it correctly. Random returns a long variable result and you defined you two variables as being long type.

And does it matter what pin I use, I just said 12 because it was originally 13, but I changed it because there's an LED there. Is any other pin more appropriate?

You selected a good pin to use. There are three pins that the arduino has something wired to, pins 0 and 1 for USB serial data communications, and pin 13 has a resistor led circuit on board. That doesn't mean you can't use those pin for other purposes, but if you can avoid using them it makes life simpler as you learn the arduino.

And finally, why "byte"?

The theory is if you are using a variable that will only hold values between 0 and 255 then defining it as a byte type will use the least amount of memory required. An int type is a 16 bit variable type so takes two bytes of memory. The processor chips used in arduino boards have very limited space for variables, arrays, and stack space that are stored in SRAM memory. This becomes a practical issue if you are writing sketches where you are trying to waste as little memory as possible. However some will say that good programming practice is to always scale variables only to the size they require.

Thanks, and sorry about the list of questions, just beginning to get to grips with this programming lingo!

Don't be sorry, questions are what this forum is all about.

(oh and sorry about putting the code in wrong :stuck_out_tongue: I'll use hash from now on!)