Show Posts
Pages: [1]
1  Using Arduino / Programming Questions / Re: Smoothing Analog values (different numReadings) on: July 01, 2012, 05:33:25 pm
The Code supplied ba PGTBOOS was straight forward..

elegant and easy way, so I got it to work

(maybe this code has more latency? or?, there must be a reason why they put this more complicated code in the examples smiley-wink )


Thanks all you guys. This forum is ***** helpful


2  Using Arduino / Programming Questions / Re: Smoothing Analog values (different numReadings) on: July 01, 2012, 05:03:47 pm
there are plus/minus buttons changeing for states

Code:

switch (remainder+1) {
  
  case 1:
  numReadings = 1;
  break;

  case 2:
  numReadings = 40;
  break;
  
  case 3:
  numReadings = 40;
  break;
  
  case 4:
  numReadings = 100;
  break;
}  


nothing special so far, just choosing a specified numReading via buttons




3  Using Arduino / Programming Questions / Re: Smoothing Analog values (different numReadings) on: July 01, 2012, 04:31:11 pm
maybe this describes better:

if the state is button=2 (numReadings = 100)and sensor value is 50% of the maximal output value (caused by my hand)

I can not get under the level of 50% when switching to button=2

understand ?
4  Using Arduino / Programming Questions / Re: Smoothing Analog values (different numReadings) on: July 01, 2012, 04:26:38 pm
thanks a lot for your answers.

I am reading from IR sensor. I know some people talking about capacity elements wich avoid this noise. but first I wanted to give the software solution a try.


with the code from dc42 I now can change numReadings. which is great. thanks alot.

but somehow changing different numReadings ( button 1= numReadings = 10 or button 2 numReadings = 100)
causes strange behaviour. the minimum value of the sensor readout seems now affected by the last value of Reading...
5  Using Arduino / Programming Questions / Re: Smoothing Analog values (different numReadings) on: July 01, 2012, 03:25:04 pm
would be nice, but then I got this error
"array bound is not an integer constant"


int readings[numReadings];      // the readings from the analog input
6  Using Arduino / Programming Questions / Smoothing Analog values (different numReadings) on: July 01, 2012, 02:53:59 pm
Hi everybody,

most of you dealing with analog sensor know the problem of jittering values.
There is this nice example in the standard arduino library called "Smoothing" (Examples>Analog).
See down
I would like to choose different Smoothing strenght in my code (with buttons).
All I want to do is to change the numReadings... but as const int
its read-only! and not changeable in later code...
Has anybody an idea ? I am really new to programming.
Help would be great

Best
Nico


Code:
const int numReadings = 10;

int readings[numReadings];      // the readings from the analog input
int index = 0;                  // the index of the current reading
int total = 0;                  // the running total
int average = 0;                // the average

int inputPin = A0;

void setup()
{
  // initialize serial communication with computer:
  Serial.begin(9600);                   
  // initialize all the readings to 0:
  for (int thisReading = 0; thisReading < numReadings; thisReading++)
    readings[thisReading] = 0;         
}

void loop() {
  // subtract the last reading:
  total= total - readings[index];         
  // read from the sensor: 
  readings[index] = analogRead(inputPin);
  // add the reading to the total:
  total= total + readings[index];       
  // advance to the next position in the array: 
  index = index + 1;                   

  // if we're at the end of the array...
  if (index >= numReadings)             
    // ...wrap around to the beginning:
    index = 0;                           

  // calculate the average:
  average = total / numReadings;         
  // send it to the computer as ASCII digits
  Serial.println(average);   
  delay(1);        // delay in between reads for stability           
}



7  Using Arduino / Microcontrollers / Re: Resetting the Arduino Uno R3 Atmega16U2 on: May 12, 2012, 03:24:08 pm
after installing dfu programmer and patching
I get this:

cortex:~ nicosteckhan$ sudo dfu-programmer atmega16u2 erase
dfu-programmer 0.5.4
Usage: dfu-programmer target command [command-options] [global-options] [file|data]
targets:
        at89c51snd1c
        at89c51snd2c
        at89c5130
        at89c5131
        at89c5132
        at90usb1287
        at90usb1286
        at90usb1287-4k
        at90usb1286-4k
        at90usb647
        at90usb646
        at90usb162
        at90usb82
        atmega32u6
        atmega32u4
        atmega32u2
        atmega16u4
        atmega8u2
        at32uc3a0128
        at32uc3a1128
        at32uc3a0256
        at32uc3a1256
        at32uc3a0512
        at32uc3a1512
        at32uc3a0512es
        at32uc3a1512es
        at32uc3a364
        at32uc3a364s
        at32uc3a3128
        at32uc3a3128s
        at32uc3a3256
        at32uc3a3256s
        at32uc3b064
        at32uc3b164
        at32uc3b0128
        at32uc3b1128
        at32uc3b0256
        at32uc3b1256
        at32uc3b0256es
        at32uc3b1256es
        at32uc3b0512
        at32uc3b1512
        at32uc3c064
        at32uc3c0128
        at32uc3c0256
        at32uc3c0512
        at32uc3c164
        at32uc3c1128
        at32uc3c1256
        at32uc3c1512
        at32uc3c264
        at32uc3c2128
        at32uc3c2256
        at32uc3c2512
global-options: --quiet, --debug level
commands:
        configure {BSB|SBV|SSB|EB|HSB} [--suppress-validation] [global-options] data
        dump [global-options]
        dump-eeprom [global-options]
        dump-user [global-options]
        erase [--suppress-validation] [global-options]
        flash [--suppress-validation] [--suppress-bootloader-mem] [global-options] {file|STDIN}
        flash-eeprom [--suppress-validation] [global-options] {file|STDIN}
        flash-user [--suppress-validation] [global-options] {file|STDIN}
        get {bootloader-version|ID1|ID2|BSB|SBV|SSB|EB|
            manufacturer|family|product-name|
            product-revision|HSB} [global-options]
        getfuse {LOCK|EPFL|BOOTPROT|BODLEVEL|BODHYST|
                BODEN|ISP_BOD_EN|ISP_IO_COND_EN|
                ISP_FORCE} [global-options]
        setfuse {LOCK|EPFL|BOOTPROT|BODLEVEL|BODHYST|
                BODEN|ISP_BOD_EN|ISP_IO_COND_EN|
                ISP_FORCE} [global-options] data
        reset [global-options]
        start [global-options]
        version [global-options]
cortex:~ nicosteckhan$




any ideas ?
Pages: [1]