0% found this document useful (0 votes)
19 views

TinkerThon Module

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views

TinkerThon Module

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 23

A way to

Think it. Build it. Tinker it

WEEK 1
🗣️“BUZZER”
What is a buzzer?
An audio signaling device which may be electromechanical or
piezoelectric or mechanical.
It converts the signal to sound.
Based on the various designs, it can generate different sounds
like alarm, music, bell & siren.
The pin configuration of the buzzer is shown below. It includes
two pins namely positive and negative. The positive terminal of
this is represented with the ‘+’ symbol or a longer terminal. This
terminal is powered through 6 Volts whereas the negative terminal
is represented with the ‘-‘symbol or short terminal and it is
connected to the GND terminal.
Working Principle:
The working principle of a buzzer,
specifically an electronic buzzer, is based on
the conversion of electrical energy into
sound. Piezoelectric buzzers use a
piezoelectric material (often a ceramic) that
deforms when an electrical voltage is applied
to it. This deformation creates mechanical
vibrations. These vibrations generate sound
waves in the audible frequency range.
Applications:
Communication Devices
Electronics used in Automobiles
Alarm Circuits
Portable Devices
Security Systems
PROJECT TIME!
It’s time to make some noise—literally! Say 🎶
hello to the Buzzer Project, your gateway to
creating interactive and sound-responsive
systems!
Project 1: Simple buzzer
Circuit diagram/ Arduino Code:

const int buzzer = 9; // Buzzer connected to Arduino pin 9

void setup() {
pinMode(buzzer, OUTPUT); // Set the buzzer pin as an output
}

void loop() {
tone(buzzer, 1000); // Send a 1 kHz sound signal to the buzzer
delay(1000); // Keep the sound on for 1 second
noTone(buzzer); // Stop the sound
delay(1000); // Wait for 1 second before repeating
}

const int buzzer = 9; // Buzzer connected to Arduino pin 9


void setup() {
pinMode(buzzer, OUTPUT); // Set the buzzer pin as an output
}
void loop() {
tone(buzzer, 1000); // Send a 1 kHz sound signal to the
buzzer
delay(1000); // Keep the sound on for 1 second
noTone(buzzer); // Stop the sound
delay(1000); // Wait for 1 second before repeating
}
“Let me walk you through the code that makes your
buzzer beep like a pro. ”🚀
1. const int
Declare the name where the buzzer is connected to
arduino uno.
2. void setup() and void loop()
It's the main function in a program without this the
program won't execute.
3. void setup()
declare whether the given pin is used to give input or
output to the sensor and also used to perform some
actions we will discuss about this in the next project.
4. pinMode (_____,______)
It is used to declare the pin(element) is used for input or
output.
5. void loop()
used to perform some action on the sensor continuously.
6. tone (_____,_____)
It is a function of a buzzer which is used to give output
sound and it has two parameters, 1st parameter takes the
pin number of the arduino(in above given code pin number
is declared using buzzer as name)and 2nd parameter takes
the frequency.
7. delay()
It is a function where it produces a stop or delay after
performing some action.
8. noTone()
It is a function used to not give the output sound.
"Fantastic work, Innovators! 🎉
It's time to tune your
buzzer and turn it into a music maestro for your Sa Re
Ga Ma Pa project. 🥁🎶
Project 2: SA-RI-GA-MA-PA using buzzer
Circuit diagram/ Arduino Code:

int melody[] = {262, 294, 330, 349, 392, 440, 494, 523};
int noteDuration = 1000;
void setup() {
pinMode(8, OUTPUT);
//put this portion of the code inside the void loop if required.
for (int i = 0; i < 8; i++) {
tone(8, melody[i]);
delay(noteDuration);
noTone(8); // no tone for the duration specified by noteDuration
delay (noteDuration);
for (int j = 7: j >=0; j -- ) {
tone(8, melody[j]);
delay(noteDuration);
void loop() {
}
"Innovators, now let us understand each step of
the code. 🥁🎶
To produce SA-RI-GA-MA-PA we need different frequencies for
different notes. So if we declare every note and pass it to the
tone function it will become complex and lengthy code. To avoid
this we will go with an array concept and to produce every note
we will loop through it using for loop and array indices.

In the above piece of code


1. We declared an array named melody consisting of different
integer frequencies.
2. Also we declared note duration as 1000, without declaring
also we can pass the value to the delay parameter. By
declaring it makes our code easier.
3. Array declaration is as follows
type_arrayname[]={values};
4. void setup()
It is used to declare the pinMode to give input or output to
the sensor and also used to perform some actions on the
sensor.
As array is declared we need the loop to pass every value to
the tone function.
Here we are using a for loop.
syntax
for(initialization; condition;increment or decrement){
statement 1;
:
statement n;
}
Using a for loop we will pass different values to tone
function by using a declared array.
5. void loop()
It is mentioned as it is the main function. Without this
function, code will not work so that the void loop is just
mentioned and not used.
Tone, noTone , delay are the same functions used in 1st
project and it has the same functionality.
🗣️PUSH BUTTON
What isis Push-Button?
What Push-Button?
A push-button is a simple type of mechanical switch that allows
or interrupts the flow of current in an electrical circuit. It is
activated when the button is pressed and deactivated when
released (momentary action) or toggled between states
(latching action).

Your paragraph text

Applications of Push Buttons


Applications of Push Buttons
1. Consumer Electronics: Keyboards, remote controls.
2. Home Appliances: Washing machines, microwaves.
3. Industrial: Control panels, emergency stop systems.
4. Automotive: Start/stop buttons, horns.
5. IoT/Smart Systems: Home automation controls.
6. Medical: Diagnostic equipment interfaces.
7. Gaming: Arcade and simulation controls.
8. Security: Alarms and emergency triggers.
9. DIY Projects: Prototyping and circuit experiments.
PROJECTS
PROJECTS
“When you press this button, I can turn on an
LED. Ta-da!”
PROJECT 1: LED controlling using Push-Button
CIRCUIT DIAGRAM

CODE
LED pin
int ledPin = 7;
// Button pin
int buttonPin - 2; void setup () f
// Set LED pin as output pinMode (ledPin, OUTPUT) :
// Set button pin as input with internal pull-up resistor
void 100p () I
/Read the state of the button pin int buttonState - digitalRead (buttonPin) ;
// Check if button is pressed
if (buttonState -= LOW) f
// Button pressed, turn LED On
digitalWrite (ledPin, HIGH) ;
else l
/ Button not pressed, turn LED Off digitalWrite (ledPin, LOW);
}
}
LETS GET A STEPWISE UNDERSTANDING

ledPin: Specifies the pin number connected to the LED. Here


the LED is connected to digital pin 7.
buttonPin: Specifies the pin number connected to the button.
The button is connected to digital pin 2.
SETUP() FUNCTION:
pinMode(ledPin, OUTPUT): Configures the ledPin (7) as an
output pin to control the LED.
pinMode(buttonPin, INPUT_PULLUP): Configures the
buttonPin (2) as an input pin with an internal pull-up resistor.
When the button is not pressed, the pull-up resistor ensures
the pin reads HIGH.loop() Function:
When the button is pressed, it connects to ground, and the
pin reads LOW.
loop() Function:

nt buttonState = digitalRead(buttonPin): Reads the current


state of the button pin (LOW or HIGH) and stores it in the
buttonState variable.
if (buttonState == LOW): If the button is pressed
(buttonState == LOW)
Turn the LED on by setting the ledPin (7) to HIGH.
else:
If the button is not pressed (buttonState == HIGH)
Turn the LED off by setting the ledPin (7) to LOW.
Project 2: Simple Counter with Arduino
CircuitDiagram
Circuit Diagram

CODE
const int buttonfin - 2; const int ledPin - 9; / variables will, change:
int buttonState = 0; int count value =0: int prestate =0;
void setup () l
// initialize the LED pin as an output:
pinMode (LedFin, OUTPUT) :
// initialize the pushbutton pin as an input:
pinMode (buttonPin, INPUT) :
Serial. begin (9600) :
}
VOID LOOP(){
/ read the state of the pushoutton value:
buttonState = digitalRead (buttonPin) ;
// check if the pushbutton is pressed. If it 19, then the buttonstate is HIGH:
it (buttonState - HIGH && prestate -- 0) l
count value++:
Serial. printin (count_value) ;
// turn LED on digitalWrite (ledPin, HIGH) :
delay (100) ;
//turn TED off
digitalWrite (ledPin, LOW):
prestate =1;
}
else if (buttonstate LOW) t
prestate = 0;
}
CODE EXPLANATION
CODE EXPLANATION
buttonPin: The pin connected to the pushbutton (digital pin 2).
ledPin: The pin connected to the LED (digital pin 9).
buttonState: Holds the current state of the pushbutton (HIGH when
pressed, LOW otherwise).
count_value: Tracks how many times the button has been pressed.
prestate: Stores the previous state of the button to detect a
transition from unpressed to pressed.
setup()Function
setup() Function :
pinMode(ledPin, OUTPUT): Configures the ledPin (9) as an output
pin to control the LED.
pinMode(buttonPin, INPUT): Configures the buttonPin (2) as an
input pin to read the state of the pushbutton.
Serial.begin(9600): Initializes serial communication at 9600 baud,
enabling you to send data to the Serial Monitor for debugging.
loop()Function:
loop() Function:
buttonState = digitalRead(buttonPin): Reads the current state of the
pushbutton (HIGH when pressed, LOW otherwise) and stores it in
buttonState.
DetectingaaButton
Detecting ButtonPress:
Press:
buttonState == HIGH: The button is currently pressed.
prestate == 0: Ensures this is a new press (the button was not
pressed in the previous loop iteration).
Increment
IncrementCounter:
Counter:
count_value++: Increments the counter by 1 to track the number of
button presses.
Serial.println(count_value): Sends the updated count to the Serial
Monitor for debugging or display.
Control the LED:
digitalWrite(ledPin, HIGH): Turns the LED on.
delay(100): Keeps the LED on for 100 milliseconds.
digitalWrite(ledPin, LOW): Turns the LED off after the delay.
Sets prestate to 1 to indicate that the button is currently pressed,
ensuring the counter does not increment repeatedly while the button
remains pressed.
buttonState == LOW: Detects when the button is released.
prestate = 0: Resets prestate to allow detecting a new button press in
the next loop iteration.
🗣️“LED”
What is LED?
LED (Light Emitting Diode) is a semiconductor device that produces light when an
electric current passes through it.
It operates based on the principle of electroluminescence, where energy released by
electrons recombining with holes in the semiconductor emits photons, creating light.

Working of LED
The electrons are majority carriers in N-type and holes are majority carriers in P-
type.
The electrons of N-type are in the conduction band and holes of P-type are in the
valence band. The energy level of the Conduction band is higher than the energy
level of the Valence band.
If electrons tend to recombine with holes they have to lose some part of the energy
to fall in the lower energy band.
The electrons can lose their energy either in the form of heat or light. The electrons
LED
in Silicon and Germanium lose their energy in the form of heat.
Thus, they are not used for LEDs as we want semiconductors in which electrons lose
their energy in the form of light.
The primary materials that are used are Gallium Arsenide(GaAS),Aluminium gallium
arsenide(AlGaAs).
APPLICATIONS:
Lighting
Displays
Automotive
Medical: Applied in surgical
lights, phototherapy, and
endoscopy lighting.
Consumer Electronics:
Backlighting for smartphones,
laptops, and wearables.
🗣️TIME FOR SOME PROJECTS
Project 1: BLINKING OF LED
CODE BLOCK
CIRCUIT DIAGRAM:
void setup() {

pinMode (13, OUTPUT);

void loop() {

digitalWrite(13, HIGH);

delay(1000);

digitalWrite(13, LOW);

delay(1000);

EXPLANATION: }

🗣️:”LET ME BREAKDOWN THE CODE FOR YOU”


1. void setup (): to declare whether the given pin is used to give input
or output to the sensor.
2. void loop (): is used to perform some action on the sensor.
3. pin mode (): is used to set the specific pins on a microcontroller
(like an Arduino) to be output pins.
4. digital write (): is used because it allows for precise control over
the individual LED lights, turning them on and off at specific times to
accurately mimic the sequence of a real traffic light.
5. delay ():is a function where it produces a stop or delay after
performing some action.
Project 2: Traffic light simulation using LED
CIRCUIT DIAGRAM: CODE BLOCK

// Define LED pins

const int redLED = 13;


const int yellowLED = 12;
const int greenLED 11;

void setup() {

// Set LED pins as output


EXPLANATION: pinMode (redLED, OUTPUT);
pinMode(yellowLED,OUTPUT);
🗣️:”LET ME BREAKDOWN THE pinMode (greenLED, OUTPUT);
CODE FOR YOU” }
void loop(){
1. const int is used to define // Red light
digitalWrite (redLED, HIGH);
variables representing the pin
delay(5000); // Wait for 5 seconds
numbers connected to the digitalWrite(redLED, LOW);
LEDs, ensuring that these values // Yellow light
digitalWrite(yellowLED, HIGH);
remain constant throughout the delay (2000); // Wait for 2
program and cannot be seconds digitalWrite(yellowLED,
LOW);
accidentally changed.
// Green light
2. void setup and void loop are digitalWrite(greenLED,HIGH);
the main functions in any delay(5000); // Wait for 5 seconds

program without this the code digitalWrite(greenLED, LOW);

will not execute the program.


3. void setup is used to declare whether the given pin is used
to give input or output to the sensor.
4. void loop is used to perform some action on the
sensor.
5. pin mode is used to set the specific pins on a
microcontroller (like an Arduino) to be output pins.
6. digital write is used because it allows for precise
control over the individual LED lights, turning them
on and off at specific times to accurately mimic the
sequence of a real traffic light.
7. delay is a function where it produces a stop or
delay after performing some action.
🗣️“POTENTIOMETER”
What is a Potentiometer ?
A potentiometer is a type of
variable resistor.
It is used to adjust or control
the level of voltage in a circuit.
It consists of a resistive
element.
It has a movable wiper (or slider)
that moves along the resistive
element
Working Principle:
Controls voltage by acting as a voltage divider.
Has three terminals:
Two connected to a resistive element.
One connected to a movable wiper.
Changes the resistance between the wiper and the terminals.
Varies the output voltage by adjusting the wiper.
Adjusts voltage or signal levels in a circuit.
Vcc(Voltage Common Collector): Connected to one end of the
potentiometer (positive voltage)
Ground: Connected to the other end (0V or negative voltage).
Output: The variable voltage that can be adjusted using the wiper.

Types of Potentiometer: Applications:


Volume & Tone Control
in Audio Devices.
Light Dimmers.
Position Sensing (Joystick,
Robotics, etc.)
Adjustable Power
Supplies.
Analog Signal Processing.
🗣️TIME FOR SOME PROJECTS
1.LED Brightness Control:
CIRCUIT DIAGRAM: CODE BLOCK

int p=0;
void setup()
{
pinMode (9, OUTPUT);
pinMode (A5, INPUT);
}
EXPLANATION: void loop()

🗣️ :”LET ME BREAKDOWN
{
p-analogRead (A5);
THE CODE FOR YOU” digitalWrite(9, HIGH);
delay(p); // Wait for 1000
analogRead(A5): Reads the analog
millisecond(s)
value from pin A5, which can range digitalWrite(9, LOW);
from 0 to 1023. This value is stored in delay(p); // Wait for 1000
the variable p. millisecond(s)
digitalWrite(9, HIGH): Sets pin 9 to }
HIGH (turning on the LED or buzzer).
delay(p): The delay is based on the
analog reading from pin A5, making
the delay vary depending on the
input.
digitalWrite(9, LOW): Turns off pin 9 (turning off the LED or
buzzer).
delay(p): Waits again before repeating the loop.
Controlling Buzzer :
CIRCUIT DIAGRAM:

CODE BLOCK

// Define the pin connected to the piezo buzzer


const int buzzerPin 9; // You can connect the buzzer to
digital
// Set the frequency (in Hz)
const int frequency 1000; // Set to 1000 Hz (1 kHz)
void setup() {
// No need for setup configuration for piezo buzzers
}
void loop() {
// Play tone on the buzzer with the specified frequency
tone (9, 1000);
// Keep it playing for 1 second (1000 milliseconds)
delay(1000):
// Stop the buzzer
noTone(9);
// Wait for 1 second (optional delay)
delay(1000); }
EXPLANATION:
🗣️:”LET ME BREAKDOWN THE
CODE FOR YOU”

buzzerPin: The pin where the piezo buzzer is


connected (pin 9 in this example).
frequency: Set to 1000 Hz. You can change
this to any other frequency.
tone(): This function plays a sound on the
buzzer at the specified frequency.
noTone(): Stops the sound from the buzzer
“Here is your assignment 1 for you innovators! 💡
Let’s put on our thinking caps and get creative! 🚀”
1. Develop a circuit diagram for the given below code (5
points)
Description: Use a push button to cycle through turning on
multiple (3 LEDs) LEDs in sequence.
ARDUINO CODE:
const int buttonPin = 2; // Push button pin
const int ledPins [] = {9, 10, 11); // LED pins
const int ledCount = 3;
int currentLed = 0;
int buttonState;
int lastButtonState = LOW;
void setup () {
pinMode (buttonPin, INPUT) ;
for (int i = 0; i < ledCount; i++) {
pinMode (ledPins [i], OUTPUT) ;
void loop () {
buttonState = digitalRead (buttonPin) ;
if (buttonState == HIGH && lastButtonState == LOW) {
currentLed = (currentLed + 1) & ledCount; // Cycle throug
delay (200) ;
// Debounce
}
lastButtonState = buttonState;
// Turn on the current LED, off the others
for (int i = 0; i < ledCount; i++) {
digitalWrite (ledPins [i], i == currentLed ? HIGH : LOW) ;
}
}
2.DEVELOP THE CODE FOR THE GIVEN CIRCUIT
DIAGRAM (5 points)
Description: Use a potentiometer to control the volume or
frequency of a buzzer. The louder or higher the pitch, the
more urgent the alert.

CIRCUIT DIAGRAM:

BONUS QUESTION (5 points)


Develop the code and circuit diagram for the given below
description.
Description:
The circuit simulates a basic security system. The potentiometer
sets a threshold for an alert condition, the push button acts as an
activation switch for the system, the LED represents the alarm
status, and the buzzer serves as the alert sound. If the threshold
set by the potentiometer is exceeded (simulating a sensor reading
like temperature or distance), the LED and buzzer are triggered to
alert you.

You might also like