From c492a1ade1266a51eaf8842226f56f68bc37cfc2 Mon Sep 17 00:00:00 2001 From: "Robert L. Carpenter" Date: Fri, 4 Mar 2011 14:01:34 -0700 Subject: [PATCH] Working at 1/10th a second intervals now. --- handrail.pde | 103 +++++++++++++++++++++++++-------------------------- 1 file changed, 51 insertions(+), 52 deletions(-) diff --git a/handrail.pde b/handrail.pde index e68dd26..9ac480e 100644 --- a/handrail.pde +++ b/handrail.pde @@ -1,10 +1,10 @@ -#define NETWORK_SIZE 24 +#define NETWORK_SIZE 12 #define NETWORK_DEPTH 13 #define AVG_DIVISOR 3 //there are 8 spots for the chip to average, so historical data is weighted pretty heavily -#define DIFF_THRESHOLD 100 -#define DETECT_COUNT 3 +#define DIFF_THRESHOLD 50 +#define DETECT_COUNT 2 #define BOARD_SELECT_SLOT 0 #define NIBBLE_SLOT 1 @@ -31,22 +31,19 @@ int network[NETWORK_SIZE][NETWORK_DEPTH] = { {2,11,0,0, 0,0,0}, {2,12,0,0, 0,0,0}, -//* - {1,0, 0,0, 0,0,0}, - {1,1, 0,0, 0,0,0}, - {1,2, 0,0, 0,0,0}, - {1,3, 0,0, 0,0,0}, - {1,4, 0,0, 0,0,0}, - {1,5, 0,0, 0,0,0}, - {1,7, 0,0, 0,0,0}, - {1,8, 0,0, 0,0,0}, - {1,9, 0,0, 0,0,0}, - {1,10,0,0, 0,0,0}, - {1,11,0,0, 0,0,0}, - {1,12,0,0, 0,0,0}, - - -}; /* */ + //{1,0, 0,0, 0,0,0}, + //{1,1, 0,0, 0,0,0}, + //{1,2, 0,0, 0,0,0}, + //{1,3, 0,0, 0,0,0}, + //{1,4, 0,0, 0,0,0}, + //{1,5, 0,0, 0,0,0}, + //{1,7, 0,0, 0,0,0}, + //{1,8, 0,0, 0,0,0}, + //{1,9, 0,0, 0,0,0}, + //{1,10,0,0, 0,0,0}, + //{1,11,0,0, 0,0,0}, + //{1,12,0,0, 0,0,0}, +}; int current_value_slot = VALUE_HISTORY_START; @@ -91,17 +88,17 @@ void loop(){ read_sensors(current_value_slot, network); //Serial.println(current_value_slot); - //print_network(network); + print_network(network); digitalWrite(13,state); state = ! state; increment(); - delay(1000); + delay(50); ////Serial.println(VALUE_HISTORY_END); - Serial.println(); Serial.println(); Serial.println(); - Serial.println(); Serial.println(); Serial.println(); - Serial.println(); Serial.println(); Serial.println(); + //Serial.println(); Serial.println(); Serial.println(); + //Serial.println(); Serial.println(); Serial.println(); + //Serial.println(); Serial.println(); Serial.println(); } @@ -121,15 +118,14 @@ void zero_detect_pins(){ void print_network(int network[][NETWORK_DEPTH]){ for (int i=0; i < NETWORK_SIZE; i++){ - for (int j=0; j < NETWORK_DEPTH; j++){ - // Serial.print(network[i][DETECT_SLOT]); - Serial.print(network[i][j]); - Serial.print(' '); - } - Serial.println(); - if (i == 11) - Serial.println(); + //for (int j=0; j < NETWORK_DEPTH; j++){ + Serial.print(network[i][DETECT_SLOT]); + // Serial.print(network[i][j]); + // Serial.print(' '); + //} + Serial.print(' '); } + Serial.println(); } void read_sensors(int into_slot, int network[][NETWORK_DEPTH]){ @@ -163,26 +159,29 @@ int read_sensor(int network_port, int into_slot, int network[][NETWORK_DEPTH]){ int diff = port[into_slot] - avg; - Serial.print("into_slot:"); - Serial.print(into_slot); - Serial.print(" "); - - for (int i=0; i DIFF_THRESHOLD){ port[DETECT_COUNT_SLOT] ++; @@ -194,6 +193,6 @@ int read_sensor(int network_port, int into_slot, int network[][NETWORK_DEPTH]){ port[DETECT_COUNT_SLOT] = 0; } - if (! digitalRead(7)) - delay(100); + if (port[DETECT_SLOT] > 60) + port[DETECT_SLOT] = port[DETECT_COUNT] = 0; }