Counter program

I need to write a program that utilizes the following parts: -arduino (of course) -magnet switch (mechanical, thin metal disk) -relay -48vdc motor -48vdc power supply (I will have a separate 5v power supply for the arduino) -mechanical power switch -magnet

The purpose of this program is this: when the motor is running, it's spinning a magnet which is attached to the shaft of the motor that goes by a magnet switch every rotation. Once 10 rotations are completed, I want the relay to power off the motor. Then I flip the power switch and the process starts all over again (this step I suppose doesn't even need to be programmed, the program should stop after 10 rotations). Rotations would be recognized using the on/off cycle of the magnet switch as the magnet on the motor shaft passes the magnet switch. This should be really simple to write except that I'm not an arduino/C# programmer. Thanks in advance for any assistance!

You have our permission.

... or what there a programming question there?

I'm not an arduino/C# programmer

even someone as new as myself may be able to code that in C++ to do all that, at my stage it would be impossible without the hall switch or whatever kind of switch your counting with.

if (switch==10){

but this sounds like it wouldnt be too hard to do, start with the examples and work your way through.

Arrch: You have our permission.

... or what there a programming question there?

I just simply wanted to know if you are always a dick or just act like one on internet forums?

This will work if you reset the counter afterwards.

if (switch==10){ digitalWrite(motorRelay,LOW)}

But, you can also use the module operator ( % ), and have something like this.

if (switch % 10 == 0){

I was looking for the same thing. Every time the reed switch is closed you want to know that the motor went a revolution shows this functionality.

"The sketch below continually reads the button's state. It then compares the button's state to its state the last time through the main loop. If the current button state is different from the last button state and the current button state is high, then the button changed from off to on. The sketch then increments a button push counter."

I want to use this to operate a linear actuator for a satellite dish position. I would like to be able to store the number of button pushes and change the position up or down by comparing the current position to the desired position.

In this way I want to track the sun for a parabolic solar hot water heater.