Folks,
Sorry it has been a while for me writing sketches.
This is my recent effort to make a programmable STROBE.
For now it pulses pin 13.
I enter the frequency via the serial port/USB.
The lower part of the code is where the frequency is "made".
I put the "if frequency >1" because (obviously) you can't have anything less than 1.
But with that, nothing happens.
If I remove that condition it blinks the LED.
Yeah, I am missing something obvious, but it illudes me.
Any one - please?
#define outputpin 13
String Sfrequency = "";
int frequency;
void setup()
{
// put your setup code here, to run once:
Serial.begin(9600);
}
void loop()
{
// put your main code here, to run repeatedly:
while (Serial.available() > 0)
{
//
int newchar = Serial.read();
//Serial.println("This is a test");
//Serial.print("{test line ");
//Serial.print(newchar);
//Serial.println(" }");
if (isDigit(newchar))
{
//
Sfrequency += (char)newchar;
}
if (newchar == '\n')
{
//
Serial.println("frequency");
Serial.println(Sfrequency);
Serial.println("Value");
Serial.println(Sfrequency.toInt());
frequency = Sfrequency.toInt();
Serial.println(frequency);
Sfrequency = "";
}
}
if (frequency > 1)
{
digitalWrite(outputpin, HIGH);
delay(1000/(2*frequency));
digitalWrite(outputpin, LOW);
delay(1000/(2*frequency));
//Serial.println(" Done ");
}
}