I have an array of numbers that will be subtracted from the ADC readings
of a 50 Hz sine wave. Using Serial.begin(57600);
, I can only
output 25 samples per sine wave cycle, or about 1,250 samples per
second. my questions are:
- how fast the increent of array number moves with y++ in my int sinus[]? because when i see on serial monitor with 52700 baudrate it can only show about 25 numbers per cycle (50Hz)
- how to increase the speed the increment of y++ in my array?
int sinus[] = {
70, 72, 83, 92, 108, 132, 157, 182, 207, 230, 243, 255, 255,
255, 250, 238, 217, 193, 169, 143, 118, 98, 88, 77, 72, 80
};
int dataSensor;
int hasil[26];
int datasensor2;
int dataBaru;
int x;
int y;
int intPin = 2;
int output;
int output2;
int toggle;
int toggle2;
int z;
void setup() {
TCCR1A = 0b00000010;
TCCR1B = 0b00011100;
TCCR0A = 0; //disable millis, delay and mciros
TCCR0B = 0;
ICR1 = 3200;
Serial.begin(57600);
pinMode(A1, INPUT);
pinMode(A0, INPUT);
pinMode(A2, INPUT);
pinMode(intPin, INPUT);
pinMode(9, OUTPUT);
pinMode(10, OUTPUT);
attachInterrupt(0, genJeah, RISING);
}
void genJeah() { //intrupsi rising
y = 5;
}
void loop() {
dataSensor = analogRead(A0);
toggle = digitalRead(A1);
toggle2 = digitalRead(A2);
dataBaru = map(dataSensor, 0, 1023, 0, 255);
for (x = 0; x < 25; x++) {
hasil[x] = sinus[x];
}
// for (x=0; x<100; x++){
output = sinus[y] - dataBaru;
Serial.println(output);
y++;
if (y > hasil[26]) {
y = 0;
}
}
move number
mean? – jsotola May 3 '19 at 3:45