OMG that great but I have little problem Can it loop for like atleast 10sec maybe more. Not its like doing something for idk 500ms? something like that. I thought its thanks to sensor. I would like if it could loop hold highest value until I reset it with some kind of reset button. I would like not to use Arduino reset since its take a while to boot. I know its kinda much but as I said I have no idea how it works and how to extend that reading time.
It doesnt work “exit status 1” I need to get something like:
spikeValue //that will be just tip of the pulse and it will not be always same. So on scale from 0-1023 once it will be just 250 next 700, etc… Just like on those equalizers where when you seen drop it would skyrocket and stay there for sec. I need just that and stay for idk 10sec.
Hey guys I know its hard with me but Im learning so much. When I arrived here first I knew just how to change delay on blink. Thanks for help.
I moved some things to make it easier for me to see clearly quick and easy.
int potPin = A0;
int LEDPin = 3; // I need to use PWM output
int readValue, lastRead;
unsigned long writeValue; // to get the calculation done better, without using floats
pinMode( potPin, INPUT );
pinMode( LEDPin, OUTPUT );
Serial.begin( 115200 ); // change your serial monitor to match
// faster serial clears the serial output buffer faster, 9600 is dismally slow
readValue = analogRead(potPin);
if ( lastRead > readValue )
readValue = lastRead;
lastRead = readValue;
writeValue = readValue; // puts the 16 bit signed value 0-1023 into unsigned long.
writeValue = writeValue * 255UL / 200UL; // less lossy, 1023 becomes 1304
analogWrite(LEDPin, readValue / 4 ); // PWM can be 0-255. -1 may be same as 255
delay(100); // this is more likely to cause missing the full pulse than not
There should probably be logic to stop reads once they fall to low value and get rid of the delay. It'd allow lastRead to be made zero and another whack measured.