Is there an easy way to do this with B4R?
the 38000 runs continuously. It does not care about the other delays, or the rest of the program.
Thank you, Lee
B4X:
int led = 1;
void setup ()
{
pinMode(led, OUTPUT);
tone (0, 38000);
}
// the loop routine runs over and over again forever:
void loop() {
digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(led, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
}
@Lee Ingram, @Erel said that you can use the internal tone command with simple inline C code. If I'm correct what you want is the following code. You will need to create the pitches.h file in the Arduino IDE, CLICK HERE.
I've not tested the following code but hopefully it should work for you.
B4X:
Sub Process_Globals
'These global variables will be declared once when the application starts.
'Public variables can be accessed from all modules.
Public Serial1 As Serial
End Sub
Private Sub AppStart
Serial1.Initialize(115200)
Log("AppStart")
RunNative("Tone", Null)
End Sub
#if C
#include <pitches.h>
void Tone (B4R::Object* unused) {
tone(2, NOTE_FS7, 1000); //Pin, Tone, Duration
//tone(2, NOTE_FS7); //Pin, Tone
}
#End if