hi guys,
i have a problem.
I have programmed an frequency gene. and it all works well, but now i thought i would be nice to let the pc communicate with arduino board to change the frequencys without uploading a new software at the board.
Here the Code
Code:
int fr1=640,fr2=533,fr3=457,fr4=400,fr5=355;
int fr1d=40;
int tim=0,tim2=0,tim3=0,tim4=0,tim5=0;
int funktionsaufruf=0;
int count=0;
int val1[15];
int param[7];
int mult=1;
int mult_cur=0;
int freq_cur=0;
int c=0;
char command[20];
void setup()
{
TCCR1A = ( (1 << COM1A0) | (1 << COM1B0));
//TCCR1B = ( (1 << CS11) | (1 << CS10) );
TCCR1B = ( (1 << CS10) );
TIMSK1 = (1 << OCIE1A);
sei();
OCR1A = 250;
DDRB |= ( (1 << PB1) | (1 << PB2) | (1 << 0) );
DDRD |= ( (1 << 2) | (1 << 3) | (1 << 4) | (1 << 5) | (1 << 6) );
Serial.begin(9600);
}
void loop()
{
if((Serial.available() > 0) && (count < 15) ){
val1[count] = Serial.read();
Serial.flush();
count++;
}
if((Serial.available() == 0) && count >= 15)
{
Serial.flush();
for(int i=0;i<15;i++)
Serial.print(val1*,BYTE);*
count =0;
}
}
ISR(TIMER1_COMPA_vect) {
- OCR1A = OCR1A + 250;*
tim=tim+1;
tim2=tim2+1;
tim3 += 1;
tim4 += 1;
tim5 += 1;
if(fr1 == tim){
-
PORTD ^= (1 << 6);*
-
tim =0;*
-
}*
if(fr2 == tim2){
-
PORTD ^= (1 << 5);*
-
tim2 =0;*
-
}*
-
if(fr3 == tim3){*
-
PORTD ^= (1 << 4);*
-
tim3 =0;*
-
}*
-
if(fr4 == tim4){*
-
PORTD ^= (1 << 3);*
-
tim4 =0;*
-
}*
-
if(fr5 == tim5){*
-
PORTD ^= (1 << 2);*
-
tim5 =0;*
-
}*
}
So the Program should readsomething and give it back.
the problem is that after an reboot, by pushing the button on the board or opening and closing the Serial Monitor in the arduino software (i have read it does also reboot the board), the program doesn't work , only after uploading the software again it does work, so what can it be
(my english isn't perfect, so if something isn't clear just ask)
so thanks.