Speedometers often use a spinning disk that has alternating black and white strips such as this one:

A light sensor measures the color, receiving a stream of zeroes (black) and ones (white), such as

0 0 0 0 1 1 1 1 1 1 0 0 0 0 0 0 0 1 1 1 1 1 1 1 0 0 0 0 0 0 0 1 1 1 1 1 1 0 0 0 ...

Each sensor measurement is communicated by a separate call to the add method:

SpinningDisk disk = new SpinningDisk();
disk.add(0);
disk.add(0);
disk.add(0);
disk.add(0);
disk.add(1);
disk.add(1);
disk.add(1);
disk.add(1);
disk.add(1);
disk.add(1);
disk.add(0);
 ...

The length of each segment is an indication of the speed: the slower the speed, the longer the segment. In your implementation, count the number of transitions (from 0 to 1 and from 1 to 0) and measure the length of the current segment. You need to increment the counter and reset the length when the inputs flip from ones to zeroes or zeroes to ones.

Each call to add needs to know the previously seen value so that it can update the counter and the length. You need to figure out how that value is updated. Set it to zero when the object is constructed.