I'm not sure I understand the question; you don't appear to use "buffer" for anything, but you're happy to endure the potential collateral damage associated with writing to it.
AWOL:
I'm not sure I understand the question; you don't appear to use "buffer" for anything, but you're happy to endure the potential collateral damage associated with writing to it.
many many thanks!!!!
first, I made simple project
void setup() {
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
}
// the loop routine runs over and over again forever:
void loop() {
// read the input on analog pin 0:
int sensorValue = analogRead(A0);
// Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V):
float voltage = sensorValue * (5.0 / 1023.0);
// print out the value you read:
Serial.println(voltage);
}
I check the ADC ,
I receive about 2 v more or less when have nothing on ADC input
I receive zerroo when I connect pulse positives up to 5v more pulses are about volt
I receive may the correct pulses-voltage when I connect only the ground on arduino from my pcb board about volt or lower , 0,05v 0,70v...
may daMAnge ADC ON Arduino???
dut the project with potensiometer on adc woork correct....give me different numbers - values when I change voltage with trim pot.
john44:
I receive on screen only sorting from low to high all elements butttt
I would like to show only the first of same-repetetive elements and the volume of them.
Well, how would you do this job if you were a computer?
Step through the sorted elements one at a time.
if the element is the same as the previous one, then count it.
if the element is different, then print off the previous element and its count, and start counting from one
You need some extra code to catch the start (when there is no "previous element"), and the end (to cause the final run of elements to be printed).
arduino board from china with ch... chip on board seams to be "hard to die" haha...
after day , now I upload with float arrays and float values from ADC pin the corect convertation (no buffer , ita fuction ) and I see on screen ,serial. print,float values!!!
now, I try to show non-repetitive elements of array and counts of them and I can't...
I upoload the code for this.... I see only zerro....on screen....
where is the error on the following code? it can't show me the last two 1) show only non repetetive elements and counts of them.
I try to save values in arrays with bubble sort methode but nothing.
Also, the piece of code which show the elements low to high works correct (save on thhe first one for loop array in variable and compare with the next iside for loop the array with first an d second eleent)
/*
read Analog input
*/
const int analogInPin = A0; // Analog input pin
int scinSignal;
int volEn,a,i,j = 0;
const int Energies = 20;
const int b = 20;
const int c = 20;
int energiesTable[Energies]{};
int sortTable[b]{};
int volTable[c]{};
int Table [c]{};
void setup() {
Serial.begin(9600); // initialize serial communications at 9600 bps:
}
void loop() {
///////// read and write in table energies from scin probe ////////////
Serial.print("Energy: ");
for( a=0; a<Energies; a++)
{
nextSear:
scinSignal = analogRead(analogInPin);
delay(scinSignal);
if(scinSignal == 0 || scinSignal >= 1024) { goto nextSear; }
else
{
Serial.print(scinSignal);
Serial.print("-");
energiesTable[a]=scinSignal;
}
}
///////// sorted Energies low to high //////////
for( i = 0; i < Energies - 1; i++)
{
int currentMin = energiesTable[i];
int currentMinIndex = i;
for( j = i + 1; j < Energies; j++)
{
if(currentMin > energiesTable[j])
{
currentMin = energiesTable[j];
currentMinIndex = j;
}
}
if(currentMinIndex != i)
{
energiesTable[currentMinIndex] = energiesTable[i];
energiesTable[i] = currentMin;
}
}
Serial.println();
Serial.print("sorted Energies low to high :");
for( i = 1; i < Energies; i++)
{
Serial.print(energiesTable[i]);
Serial.print("-");
}
///////// Sorted Energies - volume /////////////
for(int f = 0; f < Energies; f++)
{
int currentEqu = energiesTable[f];
for(int e=f+1; e<Energies; e++)
{
if(currentEqu != energiesTable[e]) {Table[currentEqu]; }
else { volTable[c] = ++volEn; }
}
}
Serial.println();
Serial.print("Sort Energies : ");
for(int g =0; g < b; g++)
{
Serial.print(sortTable[g]);
Serial.print("-");
}
Serial.println();
Serial.print("volume Energies : ");
for(int k = 0; k < c; k++)
{
Serial.print(volTable[k]);
Serial.print("-");
}
Serial.println();
Serial.println();
delay(5000);
}//end