Page 110 - KEC Khaitan C8.2 Flipbook
P. 110
Writing Tinkercad Code for the Buzzer
Arduino Code
void setup()
{
pinMode(8, OUTPUT);
tone(8, 523, 1000); // play tone 60 (C5 = 523 Hz)
delay(2000); // Wait for 2000 millisecond(s)
tone(8, 1661, 1000); // play tone 80 (G#6 = 1661 Hz)
delay(2000); // Wait for 2000 millisecond(s)
}
void loop()
{
delay(10); // Delay a little bit to improve simulation performance
}
REVISIT
▶ Outputs toggle devices (like LEDs) ON or OFF.
▶ Wait blocks insert time delays, orchestrating sequences.
▶ Pin assignments must match the physical wiring.
▶ Projects such as a traffic light show how we integrate multiple outputs with carefully planned timing.
108 Premium Edition-VIII

