Motorcycle gear checker!
JavaScript (ES6), 49 48 47 46 bytes

Expects:


1 for down
7 for up


f=([c,...s],g=2)=&gt;c?f(s,g-c&amp;7||g):'1N'[--g]||g


Formatted and commented

f = (                   // f is a recursive function which takes:
  [c,                   // - c = next character in input string
      ...s],            // - s = remaining characters
  g = 2                 // - g = current gear, with default = neutral = 2
) =&gt;                    //
  c ?                   // if there's still a character to process:
    f(                  //   do a recursive call with:
      s,                //     - the remaining characters
      g - c &amp; 7 ||      //     - the updated gear if it is valid
      g                 //       or the previous gear if not
    )                   //
  :                     // else:
    '1N'[--g] ||        //   decrement g and output '1' for g = 0, 'N' for g = 1,
    g                   //   or simply the corresponding digit for other values


Gears are mapped as follows:

g MOD 8 = 0 1 2 3 4 5 6 7
          ---------------
gear    = X 1 N 2 3 4 5 6       (where 'X' is an invalid state)


Which allows us to easily check the validity of the current gear with:

(g &amp; 7) != 0


Demo



f=([c,...s],g=2)=&gt;c?f(s,g-c&amp;7||g):'1N'[--g]||g

console.log(f(''))
console.log(f('1'))
console.log(f('11'))
console.log(f('17777'))
console.log(f('1777777771'))