Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding a basic example as a demonstration under GSoC 2020 #19

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added examples/02.Digital/SimpleSiren/Layout.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/02.Digital/SimpleSiren/Schematic.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
51 changes: 51 additions & 0 deletions examples/02.Digital/SimpleSiren/SimpleSiren.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
SimpleSiren

Description:
Haven't we all used horns / sirens. Just a touch on switch and siren blows.
Just a tap back and its stops honking. This library provides just this.
A bare minimum framework simulating a siren functioning.

A buzzer which is connected to digital pin 13 is blown,
when pressing a pushbutton attached to pin 2.

The circuit:
- Buzzer attached from pin 13 to ground
- pushbutton attached to pin 2 from +5V
- 10K resistor attached to pin 2 from ground

- Note: on most Arduinos do NOT come with a Buzzer on the board
hence has to be attached to pin 13.

created March 2020,
by Manthan Admane

*/

// constants won't change. They're used here to set pin numbers:
const int buttonPin = 2; // the number of the pushbutton pin
const int buzzerPin = 13; // the number of the Buzzer pin

// variables will change:
int buttonState = 0; // variable for reading the pushbutton status

void setup() {
// initialize the Buzzer pin as an output:
pinMode(buzzerPin, OUTPUT);
// initialize the pushbutton pin as an input:
pinMode(buttonPin, INPUT);
}

void loop() {
// read the state of the pushbutton value:
buttonState = digitalRead(buttonPin);

// check if the pushbutton is pressed. If it is, the buttonState is HIGH:
if (buttonState == HIGH) {
// turn Buzzer on:
digitalWrite(buzzerPin, HIGH);
} else {
// turn Buzzer off:
digitalWrite(buzzerPin, LOW);
}
}
1 change: 1 addition & 0 deletions examples/02.Digital/SimpleSiren/SimpleSiren.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
A bare minimum framework simulating a siren functioning.