Skip to content

Instantly share code, notes, and snippets.

@rakasaka
Created September 6, 2011 23:12
Show Gist options
  • Select an option

  • Save rakasaka/1199266 to your computer and use it in GitHub Desktop.

Select an option

Save rakasaka/1199266 to your computer and use it in GitHub Desktop.

Revisions

  1. rakasaka renamed this gist Sep 6, 2011. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. rakasaka revised this gist Sep 6, 2011. 1 changed file with 12 additions and 11 deletions.
    23 changes: 12 additions & 11 deletions sensor
    Original file line number Diff line number Diff line change
    @@ -7,29 +7,30 @@ HashType<int,int> hashRawArray[HASH_SIZE];
    HashMap<int,int> hashMap = HashMap<int,int>( hashRawArray , HASH_SIZE );

    void setup(){
    Serial.print("reset");
    Serial.begin(9600);
    Serial.print("reset");
    Serial.begin(9600);
    }

    void loop(){
    for (int thisPin = mini; thisPin < maxi; thisPin++) {
    int val = analogRead(thisPin);

    if (val > 200){
    int curHit = hashMap.getValueOf(thisPin);
    if ((curHit+1) > 3) {
    hashMap[thisPin](thisPin,0);
    Serial.print("#");
    Serial.print(thisPin);
    Serial.print("#");
    hashMap[thisPin](thisPin,0);
    Serial.print("#");
    Serial.print(thisPin);
    Serial.print("#");
    }
    else {
    hashMap[thisPin](thisPin,curHit+1);
    }
    } else {
    }
    else {
    hashMap[thisPin](thisPin,0);
    }
    delay(5);
    }
    Serial.println();
    }
    }
    Serial.println();
    }
  3. rakasaka created this gist Sep 6, 2011.
    35 changes: 35 additions & 0 deletions sensor
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,35 @@
    #include <HashMap.h>

    int mini = 0;
    int maxi = 16;
    const byte HASH_SIZE = 16;
    HashType<int,int> hashRawArray[HASH_SIZE];
    HashMap<int,int> hashMap = HashMap<int,int>( hashRawArray , HASH_SIZE );

    void setup(){
    Serial.print("reset");
    Serial.begin(9600);
    }

    void loop(){
    for (int thisPin = mini; thisPin < maxi; thisPin++) {
    int val = analogRead(thisPin);

    if (val > 200){
    int curHit = hashMap.getValueOf(thisPin);
    if ((curHit+1) > 3) {
    hashMap[thisPin](thisPin,0);
    Serial.print("#");
    Serial.print(thisPin);
    Serial.print("#");
    }
    else {
    hashMap[thisPin](thisPin,curHit+1);
    }
    } else {
    hashMap[thisPin](thisPin,0);
    }
    delay(5);
    }
    Serial.println();
    }