SparkFun Forums 

Where electronics enthusiasts find answers.

Your source for all things Atmel.
By trialex
#69904
OK sorry I guess I'm not getting you. I understand the math logic, but I guess it's the "usage" part that I don't understand...

are you wanting the values to change every second, or every time a button is pushed, or at some other event/interval

maybe it would help if you could say what its being used for - for example, I dunno, it's to count eggs on a conveyor belt or something
By username
#71039
Aaaaaand I'm back. Left on an extended business trip to an isolated location. Anyway, I've been thinking about what the root problem is. My code in void.loop loops(obviously) and so as it comes around the first time, it sees that switch one is high, and says "Ooh, x now equals x+a." But each subsequent loops says the same thing, and adds another instance of a to x. If I put it in void.setup, then it would get rid of this problem, but not change dynamically. Maybe if I could make the arduino see that its the same as last time and not do it again. As for what this is counting, lets just say how many of a certain mystery* gadget get produced per hour.

*The mystery is because i'm not sure my boss would like me telling the internet what it is.
By trialex
#71042
Yep that's what I was saying - what should be the signal for it to "do the count now".

You need some sort of "event" to happen to make the arduino perform the maths. This could be

[1] A button press
[2] a time period elapsing
[3] a siren sounding
[4] lights turning on
[5] etc....
By username
#71168
Yes. What I need the trigger to be is a switch. It just occurred to me, I could use a computer as sort of a bridge to execute the more complicated code that I need. If I'm going to interface between the arduino and a computer, where's a good starting point? What programming language should I use?
By trialex
#71178
Dude it's all built in!

There are arduino commands like Serial.print() that send whatever you want over the in-built serial port. The you just have whatever program you want on your PC listening for data over the serial port. You can sent it as ascii, decimal, hex, whatever you want. Heaps of examples out there too.

So by "switch" exactly what type of switch do you mean? On/off? Momentary?