Activity 1. Buzzer and LED

This activity utilizes Arduino Uno output pins to generate audio and / or visual alerts. The activity is divided into 3 parts: a) use of buzzer, b) use of LED, c) use of buzzer and LED.  (50 minutes)



Activity 1a

In this part the aim is to turn a buzzer on and off every 2.5 seconds.

Step 1. Draw the circuit in Tinkercad. A buzzer is connected to the Arduino Uno


Step 2Study the code and write it on the microcontroller:

 /*
Buzzer 
Circuit Connections:
PIN_4 => Buzzer_Positive - Buzzer_Negative = > Resistor 100Ω => Gnd
*/
//The setup() function initializes and sets the initial values
//It will only run once after each powerup or reset
void setup()
{
  //Configures the PIN_4 to behave as output
  pinMode(4, OUTPUT);
}
 //This function loops consecutively
void loop()
{
  digitalWrite(4, HIGH); //Write a HIGH value (5V) to digital pin 4 – Buzzer on
  delay(2500); // Pauses the program for 2500 milliseconds
  digitalWrite(4, LOW); //Write a LOW value (0V) to digital pin 4 – Buzzer off
  delay(2500); // Wait for 2500 milliseconds
}


Step 3Run the simulation and check the correct operation of the circuit