That is a lot closer.

A couple of minor things:

- in the loop which does the DFT you start with "for(k=1;" it should be "for(k=0;".

- You print the header " SIN COS SUM", but you print the results in the order COS SIN SUM

- the SUM that you print isn't needed. The useful number to print is the magnitude of each bin. Instead of printing sine-cosine you need to print sqrt(sine*sine + cosine*cosine).

- just FYI: the number of samples does not have to be the same as the size of the DFT. The number of samples can be, and usually is, larger than the DFT size.

In the video, he explains at one point that the numbers that you get from the DFT aren't the actual amplitudes of each frequency. You have to divide by (N/2) where N is the number of samples. So, the magnitude of each frequency bin is sqrt(sine*sine + cosine*cosine) but the amplitude of the frequency is sqrt(sine*sine + cosine*cosine)/(N/2). In your sketch the two sines (remember the header is wrong) have a value of 64. Your number of samples is 128 so dividing by 64 gives a result of 1 which is correct because both sine waves have an amplitude of 1.

Fix up your sketch to use "for(k=0;", change the header to " COS SIN SUM" and try:

input[counter] = 7*sin((2 * PI * 1 * counter) / FFTSIZE) + 10*cos((2 * PI * 8 * counter) / FFTSIZE);

In the resulting table you will now get one large spike in the SIN column corresponding to the first term (frequency 1) and an even larger spike in the COS column corresponding to the second term (frequency 8 ). When you use "for(k=0;", you count the lines starting from zero so that frequency 1 will be the second line and frequency 8 will be the ninth line.

I am finding it a little hard to understand "j"

It is the square root of -1 (and, BTW, in mathematics texts it is represented by "i" instead of "j"). If you're 13 years old, you may have run into the concept of imaginary numbers when solving the roots of a quadratic equation, but it'll be a while before you cover complex numbers which is what the DFT uses. For what you are doing, you don't need to worry about it. The number that you need from the DFT is the amplitude of each frequency and when you compute the magnitude of each frequency bin using sqrt(sine*sine + cosine*cosine), it makes the j disappear.

However, if you want to do sound localization and voice recognition you have a very long way to go.

The code isn't fast

That is one of the problems you will run into on the UNO. It does not have floating point instructions so calculations involving sin(), cos() and floating point arithmetic are very slow. You aren't going to be able to sample the data fast enough to get a meaningful result without using a lookup table for the sin/cos and other tricks to speed up the process.

Pete