Hi everyone Hope all is well.
i'm hoping (fingers crossed) some one might be able to help me.
I'll try to keep it short
in the code below is my beginners approach
it gives the general idea of what i want to do but it obviously doesn't exactly work and i'm not sure if its the right approach
I have 2 arrays a buffer and values ...the values array is just there for the moment to work things out with. (much much later it will be an analog read of some description)
the objective is to read a value from its array and buffer 7 values continuously.. so i can perform an fft calculation in slow motion to understand whats under the hood i'm just using integers for the moment just to build the framework.
any way at the moment i'm getting as an print
1 0 0 0 0 0 0 Then Calculate
2 1 0 0 0 0 0 Then Calculate
3 2 1 0 0 0 0 Then Calculate
4 3 2 1 0 0 0 Then Calculate
5 4 3 2 1 0 0 Then Calculate
6 5 4 3 2 1 0 Then Calculate
7 6 5 4 3 2 1 Then Calculate
8 6 5 4 3 2 1 Then Calculate
9 8 5 4 3 2 1 Then Calculate
10 9 8 4 3 2 1 Then Calculate
11 10 9 8 3 2 1 Then Calculate
12 11 10 9 8 2 1 Then Calculate
13 12 11 10 9 8 1 Then Calculate
14 13 12 11 10 9 8 Then Calculate
15 13 12 11 10 9 8 Then Calculate
16 15 12 11 10 9 8 Then Calculate
17 16 15 11 10 9 8 Then Calculate
18 17 16 15 10 9 8 Then Calculate
19 18 17 16 15 9 8 Then Calculate
20 19 18 17 16 15 8 Then Calculate
hopefully from this you can see what i'm trying to achieve but things fall apart as the while loop repeats and i lose the number 7
if you got this far thanks for reading : and here's a joke
Why can't you trust an Atom ??
Because they make up everything
int buffer[7]= {
0,0,0,0,0,0,0};
int values[20]={
1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20};int i = 0;
int ii = 0;
int fromarray;void setup() {
Serial.begin(9600);}
void loop() {
delay(5000);while (1){
// Serial.print("i = ");Serial.print(i); Serial.print(" ii = ");Serial.println(ii);
if (i == 0){
fromarray = values[ii];
buffer[0] = fromarray;
}if (i == 1){
buffer[1] = buffer[0];
fromarray = values[ii];
buffer[0] = fromarray;
}if (i == 2){
buffer[2] = buffer[1];
buffer[1] = buffer[0];
fromarray = values[ii];
buffer[0] = fromarray;
}if (i == 3){
buffer[3] = buffer[2];
buffer[2] = buffer[1];
buffer[1] = buffer[0];
fromarray = values[ii];
buffer[0] = fromarray;
}if (i == 4){
buffer[4] = buffer[3];
buffer[3] = buffer[2];
buffer[2] = buffer[1];
buffer[1] = buffer[0];
fromarray = values[ii];
buffer[0] = fromarray;
}if (i == 5){
buffer[5] = buffer[4];
buffer[4] = buffer[3];
buffer[3] = buffer[2];
buffer[2] = buffer[1];
buffer[1] = buffer[0];
fromarray = values[ii];
buffer[0] = fromarray;
}if (i == 6){
buffer[6] = buffer[5];
buffer[5] = buffer[4];
buffer[4] = buffer[3];
buffer[3] = buffer[2];
buffer[2] = buffer[1];
buffer[1] = buffer[0];
fromarray = values[ii];
buffer[0] = fromarray;
i = -1;
}printer();
delay(1000);
i=i++;if ( ii == 19){
break;
}
ii=ii++;}//eo while 1
while (1){
Serial.println("The End");
delay (300000);}
}//eo void
void printer(){
for(int i = 0; i < 7;i++){
Serial.print(buffer*);*
_ Serial.print(" ");_
- delay(200);*
- }*
_ Serial.println("Then Calculate");_
}
[/quote]