Go Down

Topic: need urgent help in programming arduino to drive Chladni Plate (deadline 22th 03 (Read 4 times) previous topic - next topic

antsnark

well... It was the mix of different programs. It is hard to understand ^_^

So, I tried to make the new code from the scratch.

It is the early draft  :~

Quote


char buffer[18];  //input buffer
int red, green, blue;

int RedPin = 9;   // red LED
int GreenPin = 10; //green LED
int BluePin = 11;  // Blue LED
int spkr = 13;  // speaker output
int button = 7; // button
int numChar = Serial.available();
long previousMillis = 0;   //interval
long interval = 5000;

void setup()
{
 Serial.begin(9600); //serial port
Serial.flush();  
pinMode(RedPin, OUTPUT);
pinMode(GreenPin, OUTPUT);
pinMode(BluePin, OUTPUT);
pinMode(spkr, OUTPUT);
pinMode(button, INPUT);

/*I can't manage with serial control of the tones.
And has a difficulties with logical operations to control a button
(I mean - if you press the button the frequency changes. If not -
"the interval" change the frequency)
The code to change the power of LEDs - not the problem.
I will add it later
*/

}
void loop()
{
 tone (spkr, 1000, 2000);                 // tone 1
                                           //here must be the code to change the colour of LEDs
 if (millis() - previousMillis > interval);
 
 tone (spkr, 2000, 2000);                 // tone 2
 if (millis() - previousMillis > interval);
 
 tone (spkr, 3000, 2000);                 // tone 3
 if (millis() - previousMillis > interval);

tone (spkr, 4000, 2000);                 // tone 4
 if (millis() - previousMillis > interval);
 
 tone (spkr, 5000, 2000);                 // tone 5
 if (millis() - previousMillis > interval);
 
 tone (spkr, 6000, 2000);                 // tone 6
 if (millis() - previousMillis > interval);
 
 tone (spkr, 7000, 2000);                 // tone 7
 if (millis() - previousMillis > interval);
 
 tone (spkr, 8000, 2000);                 // tone 8
 if (millis() - previousMillis > interval);
 
 tone (spkr, 9000, 2000);                 // tone 9
 if (millis() - previousMillis > interval);
 
 tone (spkr, 10000, 2000);                 // tone 10
  if (millis() - previousMillis > interval);
 
  tone (spkr, 11000, 2000);                 // tone 11
 if (millis() - previousMillis > interval);

tone (spkr, 12000, 2000);                 // tone 12
 if (millis() - previousMillis > interval);
}


AWOL

Code: [Select]
  if (millis() - previousMillis > interval);

That statement does nothing if it is true...and nothing if it is false.
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

antsnark

AWOL

this is from the example Blink Without Delay

How to do the change the frequency and LEDs colour without use of delay function?

And how to do the use of a button?

I'm stuck  :(

Now I made a mechanical part of the Chladni-plate.

AWOL

Quote
this is from the example Blink Without Delay


With the semicolon?
I don't think so.
Read the example again, carefully.
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

antsnark

stupid me  :(
:)

anyway, would You be so kind, and write correct code for serial part of the program? To change the frequencies from serial console. It is too long to compile and upload new frequencies every time.

I just don't understand how it works.

Go Up