Grade 11 Computer Engineering Final

Introduction: Grade 11 Computer Engineering Final

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

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1: Step 1: Parts List

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: 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); } } }

Step 3: Putting Everything Together

Follow the following diagram and you’ll complete the project

Be the First to Share

    Recommendations

    • Trash to Treasure Contest

      Trash to Treasure Contest
    • Raspberry Pi Contest 2020

      Raspberry Pi Contest 2020
    • Wearables Contest

      Wearables Contest

    Discussions