- AR-B1: Blinking LED Project using Arduino
- AR-B2: Alternate Control of LED & Buzzer
- AR-B3: Alternate Blinking LEDs
- AR-B4: Running Effect of LEDs
- AR-B5: Chasing Effect of LEDs
- AR-B6: Obstacle Detector using IR Sensor
- AR-B7: Object Counter using Serial Monitor
- AR-B8: Servo Motor Basic Code
- AR-B10: Car Wiper System using Servo Motor
- B13: LED Display Down Counter with Alarm using Arduino
- Protected: Day-1: Online Course on Arduino Programing with Practicals
- Protected: Day-2: Online Course on Arduino Programing with Practicals
- Protected: Day-3: Online Course on Arduino Programing with Practicals
This code is used to blink the LED connected at pin-13 of Arduino UNO and produce buzzer beeps alternately. First type the code by creating new file in Arduino IDE, save the file and then upload it.
Required Material
Arduino UNO Board – 1, data cable – 1, Red LED – 1, Resistor 1kΩ (Brown Black Red) – 1, Buzzer – 1, Jumper wires – 4.
Working
After uploading the code in Arduino UNO board, the buzzer and LED “L” will be ON alternately. This happens because of alternate action written in the code.
The Code
Upload the following code in Arduino UNO to control LED and buzzer in alternate action. It is very interesting code, which will help you understand the simple logic behind controlling number of devices using Arduino.
int LED = 7; // connect anode of LED to pin-7 int buzzer = 11; // connect +ve terminal of buzzer to pin-11 void setup() { pinMode(LED,OUTPUT); pinMode(buzzer,OUTPUT); } void loop() { digitalWrite(LED,HIGH); digitalWrite(buzzer,LOW); delay(2000); digitalWrite(LED,LOW); digitalWrite(buzzer,HIGH); delay(2000); }
Procedure & Precautions
- First type the code correctly in Arduino IDE software.
- Then connect the Arduino board to computer through data cable and click on “Tools” menu.
- Then select “Arduino board” and respective “COM” Port.
- The upload the code in Arduino UNO board.
- Observe that the LED “L” and the buzzer will be ON alternately, at a rate decided by your delay() function value.