Squirrel Repeller - a PUSH_BUTTON Model
by jzhang176 in Circuits > Arduino
235 Views, 0 Favorites, 0 Comments
Squirrel Repeller - a PUSH_BUTTON Model
This is an Arduino squirrel repeller model using a push button to imitate a weight-sensor to detect the motion of the squirrel in a flower pot and then turn the buzzer and red light on to scare the squirrel away.
This is a practice of Arduino coding. The project is a model of a squirrel repeller. The project inspiration came from the problem I have with the squirrels who constantly came to dig my flower pot during the day. I wanted to make a device to chase them away whenever they come. A motion sensor or a weight sensor may work better for this task, but because I didn't have the component supply on hand, for the practice purpose of this project, I used a push button as a replacement for the motion sensor to show the logic of the circuit and coding sketch.
This project can be reproduced by a beginner;
I used the Tinkercad Gallery as an inspiration resource for the coding of this project; and the Arduino sketch for code editing.
Supplies
1x Arduino UNO R3 Board
1x Breadboard
1x Resister (10kΩ)
1x LED (red)
1x Piezo / Buzzer
1x Push Button
1x Jumper Wire (Red)
1x Jumper Wire (Black)
5x Wires with different lengths
You can get all the supplies in an Uno Starter Kit
* A replacement for the Push Button is a Weight Sensor for Arduino. This will give the device a real function as a Squirrel Repeller when hiding it in the flower pot.
Wiring Your Arduino Boards
- Wire the 5V PIN on the Arduino UNO R3 Board with the plug hole that has a positive (+) label on the breadboard using the long red Jump Wire;
- Wire the Ground PIN on the Arduino board with the plug hole that has a negative (-) label on the breadboard, using the long black Jump Wire;
- Plug the BUZZER on the breadboard, with the two legs plugging in two different circuit lines ( or, lining up parallel to the long side of the breadboard;
- Wire one leg of the BUZZER to PIN 9 on the Arduino UNO R3 Board;
- Wire the other leg of the BUZZER to the ground line on the breadboard;
- Plug the LED on the breadboard, make sure the legs are lined up parallel to the long side of the breadboard;
- Wire the LED anode leg with PIN 6 on the Arduino UNO R3 Board;
- Wire the LED cathode leg with the 10Ω resister;
- Wire the other leg of the resistor to the GROUND line on the breadboard;
- Plug the PUSH BUTTON on the breadboard;
- Wire the anode leg of the button to PIN 7;
- Wire the cathode leg of the button to the GROUND line on the breadboard.
- If your Button does work during the testing, please switch its direction to 90°, because the legs of the button have different electrodes.
Programing Your Arduino
In this step, you need to copy-paste the following code to your Arduino Editor account, then upload it onto your Arduino UNO R3 Board. I want to credit the ArduinoGetstarted.com website for the code and tutorial materials.
The following code will allow you to turn on and off the buzzer and the LED light at the same time when you push the button. This setting simulates the situation a weight sensor for Arduino will get. Ideally, when the squirrels step into the flower pot, they press the weight sensor (button in this case), then the buzzer and LED light will be turned on and make a noise and light up the red LED to scare the squirrel away.
- Create your Arduino Editor account;
- When you sign in to your own Arduino Editor account, click sketch/ new sketch, and copy-paste the following code into your newly created file;
- Plug your wired Arduino board into your computer;
- Click the verify tab to verify and save the code;
- Click the pull-down tab on top to select the model of your Arduino Board(e.g. Arduino UNO for this sample)
- Click
const int BUTTON_PIN = 7;
const int BUZZER_PIN = 9;
const int LED_PIN = 6;
void setup() {
Serial.begin(9600);
pinMode(BUTTON_PIN, INPUT_PULLUP);
pinMode(BUZZER_PIN, OUTPUT);
pinMode(LED_PIN, OUTPUT);
}
void loop() {
int buttonState = digitalRead(BUTTON_PIN);
if (buttonState == LOW) {
digitalWrite(LED_PIN, HIGH);
tone(BUZZER_PIN, 200);
delay(500);
}
else {
digitalWrite(LED_PIN,LOW);
noTone(BUZZER_PIN);
}
}