Grade 11 Computer Engineering Final

by 881148 in Circuits > Arduino

319 Views, 0 Favorites, 0 Comments

Grade 11 Computer Engineering Final

download.jpg
When you clap your hands (or any loud noise) it will toggle a relay. In my case I have a cord connected to the relay

Step 1: Parts List

Clapper_1.jpg

Parts list:

1x Arduino

1x Breadboard

6x Female to female wires

1x Lamp

1x Wire cuter

1x Relay

1x Sound Sensor

8x Jumper Wires

Step 2: Time for Code!!

int relayPin = 10; //Relay IN1 connected to pin 7

int micPin = 11; // Mic connected to pin 6 int micVal = HIGH; //HIGH is no sound, LOW is sound

boolean pwrToggle = true;

void setup () { Serial.begin(9600); pinMode(relayPin, OUTPUT); //Set pin for output digitalWrite(relayPin, HIGH); // HIGH is off, LOW is on pinMode (micPin, INPUT) ; //Set pin for input } void loop () { micVal = digitalRead (micPin) ; // Listen... if (micVal == LOW) // Hear something!!! { if (pwrToggle == true) { //relay off (true) Turn it on and display message in serial Monitor Serial.println ("Relay on"); digitalWrite(relayPin, LOW); pwrToggle = false; delay (500); } else { //relay on (true) Turn it off and display message in serial Monitor Serial.println ("Relay off"); digitalWrite(relayPin, HIGH); pwrToggle = true; delay (500); } } }

Putting Everything Together

089FE749-6A1F-4E08-955F-F9B88F13DEF0.jpeg
Follow the following diagram and you’ll complete the project