Skip to content

Commit

Permalink
Fixed bug where analog inputs would influence each other.
Browse files Browse the repository at this point in the history
  • Loading branch information
clone45 committed Aug 9, 2014
1 parent 8e0d25f commit 19c5577
Showing 1 changed file with 6 additions and 21 deletions.
27 changes: 6 additions & 21 deletions ModuleAnalogInput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@ ModuleAnalogInput::ModuleAnalogInput(int input_pin)

uint32_t ModuleAnalogInput::read()
{

// Force the ADC to settle down and concentrate, otherwise the
// previous analogRead(..) commands on other pins will cause
// 'crosstalk' between the input values
analogRead(this->pin);
analogRead(this->pin);

// Drop the lowest bit to reduce noise, which is present on all inputs to a
// certain extent. This causes our maximum value to be 4094
this->value = (analogRead(this->pin) >> 1) << 1;
Expand All @@ -25,26 +30,6 @@ uint32_t ModuleAnalogInput::read()

this->value = constrain(map(this->value,10,4095,0,4095),0,4094);

/*
if(this->pin == PIN_PRG)
{
Serial.print("PRG: ");
Serial.print(this->value);
}
if(this->pin == PIN_SR)
{
Serial.print(" SR: ");
Serial.print(this->value);
}
if(this->pin == PIN_MOD)
{
Serial.print(" MOD: ");
Serial.println(this->value);
}
*/

return(this->value);
}

Expand Down

0 comments on commit 19c5577

Please sign in to comment.