/*
#include <Arduino.h> // Include the Arduino core library
int main() {
// Initialize the Arduino environment
init();
// Set up the pin mode for the buzzer
pinMode(13, OUTPUT);
pinMode(12, OUTPUT);
// Main program loop
unsigned long ptime = 0;
while (1)
{
if((millis() - ptime) >= 1000)
{
// Generate a tone on pin 13 with a frequency of 1000 Hz for 100 milliseconds
tone(13, 700, 200);
ptime = millis();
}
}
return 0;
}
void loop()
{
digitalWrite(12, HIGH);
delay(1000);
digitalWrite(12, LOW);
delay(1000);
}
*/
#include <Arduino.h>
/*
//C Structured codiing
// Initialize the pins
void setup() {
pinMode(12, OUTPUT); // LED
pinMode(13, OUTPUT); // Buzzer
}
int main() {
init(); // Necessary to initialize the Arduino core
setup(); // Call setup to configure the pins
while (1) {
// Generate a tone on pin 13 with a frequency of 700 Hz for 200 milliseconds
//delay(1000); // Delay to control the tone timing
// Blink the LED on pin 12
tone(13, 710, 200);
digitalWrite(12, LOW);
delay(1000);
digitalWrite(12, HIGH);
delay(1000);
}
return 0; // Should never be reached
}
*/
#include <Arduino.h> // Include the Arduino core library
void setup() {
// Set up the pin modes for the LEDs and the buzzer
pinMode(12, OUTPUT); // LED
pinMode(13, OUTPUT); // Buzzer
// Start the serial communication
Serial.begin(9600);
}
void loop() {
// Buzzer on pin 13: Generate a tone of 700 Hz for 200 milliseconds every second
tone(13, 700, 200);
//delay(1000); // Wait for a second
// Blink the LED on pin 12
digitalWrite(12, LOW);
delay(1000);
digitalWrite(12, HIGH);
delay(1000);
}