`k = 127*sin(2*3.14 * 100 * t )`

The problem is with the values of t that you use. The basic formula is, as you have it there, A*sin(2*3.14 * f * t)

where A is amplitude, f is the frequency in Hertz, and t is in seconds.

But in your loop the values of t are 0, 1, 2, 3 etc. So your code is "sampling" the 100Hz sine wave once every second - i.e. at t=0 seconds, then t=1 second, etc.

To sample the sine wave at, say, 1000Hz you would need to generate samples for t = 0, .001, .002, .003 etc. which would require that t be a floating point value and increment it by .001 each time through the loop.

For a simulated sampling rate of 38.5kHz you would need to increment t by .000025974.

With 256 samples you will be generating the equivalent of 6.65ms.

BTW, I don't know how sensitive the FFT will be to numerical errors but I would suggest that you use a more precise value for pi. use 127*sin(2*PI*100*t)

Pete