mirror of
https://github.com/arduino/Arduino.git
synced 2024-12-04 15:24:12 +01:00
22 lines
271 B
C++
22 lines
271 B
C++
int encoder = 4;
|
|
unsigned long speed = 0;
|
|
|
|
void setup()
|
|
{
|
|
pinMode(encoder, INPUT);
|
|
}
|
|
|
|
void loop()
|
|
{
|
|
speed = getspeed();
|
|
delay(1000);
|
|
}
|
|
|
|
unsigned long getspeed()
|
|
{
|
|
unsigned long duration = 0;
|
|
duration = pulseIn(encoder, HIGH);
|
|
return(duration);
|
|
}
|
|
|