Getting Synched

First time after a lot of tries. -Bill
This commit is contained in:
Bill Verplank
2012-12-07 08:15:45 -08:00
parent 0a0e857cea
commit 4c9e2ee748
23 changed files with 1849 additions and 439 deletions
@@ -0,0 +1,28 @@
int x, v, t; //position velocity time
#define n 10
int xtab[n]; //table of x
int i; // index for table
void setup()
{
// start serial port at 9600 bps:
Serial.begin(9600);
}
void loop()
{
// if we get a valid byte, read analog ins:
if (Serial.available() > 0) {
x = analogRead(A0)/4; //just for this test
xtab[i] = x; //put it in array of x
i = i + 1; //index to last x (9 times ago)
if(i>9)i=0; //increment index
v = x - xtab[i]; //difference x vs old x
t = (t+1)%256;
// send sensor values:
Serial.write(x); // sends one byte [0-255]
Serial.write(v+128);
Serial.write(t);
}
}
File diff suppressed because it is too large Load Diff