Arduino code of making a LED digit display not functioning properly
The for loop in your setup() function isn't quite right. The condition (i&lt;9) and the iterator (i++) need to be the other way round, like this:

for (int i = 2; i&lt;9; i++)
{
  pinMode (i, OUTPUT);
}