reed switch controlling servo

i have a project where a reed switch senses the wheel speed of a bicycle. the arduino then tells the servo to move a certain angle depending on wheel speed.
this is for a bicycle speedometer, but with a needle on a gauge. not the digital read out type.
the servo would move the needle on the gauge.
i need the code for this.
an array would work i imagine.
i have the servo control on output 9, and the reed switch input on input A0.
please help, thanks.
brian

How much experience have you got in using the Arduino ?

Read the number of reed switch closures over a period of time to work out the RPM of the wheel using millis() to do the timing not delay() as that would block operation of the program. You do not need to use an analogue pin for this as you will be using digitalRead() but you can use A0 as a digital pin if you need to. Once you have the RPM use the map() function with the RPM as its input and an output range to suit the servo. This will usually be from 0 to 180 but will depend on the servo and may need inverting.

How much of that do you understand ?

Probably best to search the forum for speedometer and tachometer to see previous postings

https://www.google.com/search?as_q=speedometer&as_epq=&as_oq=&as_eq=&as_nlo=&as_nhi=&lr=&cr=&as_qdr=all&as_sitesearch=http%3A%2F%2Fforum.arduino.cc%2Findex&as_occt=any&safe=images&tbs=&as_filetype=&as_rights=&gws_rd=ssl

https://www.google.com/search?as_q=tachometer&as_epq=&as_oq=&as_eq=&as_nlo=&as_nhi=&lr=&cr=&as_qdr=all&as_sitesearch=http%3A%2F%2Fforum.arduino.cc%2Findex&as_occt=any&safe=images&tbs=&as_filetype=&as_rights=&gws_rd=ssl

hi UKHeliBob ,
i understand most of it.
do you have any code that would tell the servo to move with respect to rpm/wheel speed?
the servo only needs to move 180 degrees and it would be a linear relationship.
the bicycle would have max speed of 25mph.
probably easier to do this with respect to rpm, not mph. less calcs.

The code to move the servo between 0 and 180 degrees given the RPM is easy. Look at how the map() function works.

map()

does anyone have the actual code,( not how to do it).The code to move the servo between 0 and 180 degrees given the RPM.
the max RPM is 380.
thanks

byte servoPos = map(RPM, 0, 380, 0, 180);
servo.write(servoPos);