Doorbell

Reflection

For this project I decided to stick with a very traditional doorbell, just press the “button” outside and then there will be a “ding dong” or in this case a buzzing sound. I used the code from the resources ‘7 capacitive touch sensors’ but edited it to just 2 capacitive touch sensors. I used the lid from my previous music box project as the door. Then, I just used copper tape and an alligator clip, so when I would touch the copper take from one side, there would be a buzzing sound. Once it was done it worked, but I decided to include an led on the ‘inside’ so it would notify the person inside in case they didn’t hear the buzzing. In this case I would consider this the role of (growth) mindset, since I wanted to try something new. 

However, I was not able to get it to work how I wanted it. Both the light and the buzzing sound would start as soon as I connected the negative leg of the led to a ground pin. I’m not sure if it was because I did not do the circuit part well, or if it was the coding part that I needed to change. So, I just left it like that, although it didn’t work like I thought it would, it still is an interactive project. Once I touched the negative leg of the led with the alligator clip, it started buzzing and the light flickered.  

Final product

https://photos.app.goo.gl/Rh3opjggC1fdeJeA9

Code
// 2 capacitive touch sensors: A4 - A5




#include <Adafruit_CircuitPlayground.h>


#define NOTE_G3 196




// we light one pixel at a time, this is our counter


uint8_t pixeln = 0;


int capSensorPins[] = { 3, 2 };


int numCapSensors = 2;


int ledForCap[] = { 0, 1, 3, 4, 6, 8, 9 };




// { 3, 2, 0}


// { A4, A5}


// 3 -> A4, 2 -> A5, 0




int THRESHOLD = 1000;




void setup() {


Serial.begin(9600);


CircuitPlayground.begin();


}




void loop() {




// for each pin that could be a capacitive touch sensor


for (int i = 0; i < numCapSensors; i++)


{


// print the information about what we are sensing


Serial.print("Capsense #");


Serial.print(capSensorPins[i]);


Serial.print(": ");


Serial.println(CircuitPlayground.readCap(capSensorPins[i]));




// if the value we sense is large enough


if (CircuitPlayground.readCap(capSensorPins[i]) > THRESHOLD)


// light the associated neopixel


CircuitPlayground.setPixelColor(ledForCap[i], CircuitPlayground.colorWheel(25 * i));


else


// otherwise, clear out the light for that neopixel


CircuitPlayground.setPixelColor(ledForCap[i], 0, 0, 0);


}




// let's also play a note for one of them, as an example


// we'll pick pin 3, which is labeled SCL/A4 on the board


// if the value is large enough


if ( CircuitPlayground.readCap( 3 ) > THRESHOLD)


// play the note (only if the slide switch is on)


playNote( NOTE_G3, 250 );


delay(50);


}




// Play a note of the specified frequency and for the specified duration.


// No tones will play if the slide switch is in the -/off position.


void playNote(int frequency, int duration) {


// Check if the slide switch is off


if (!CircuitPlayground.slideSwitch()) {


// stop immediately without playing anything.


return;


} else {


// Play the note for the specified duration.


CircuitPlayground.playTone(frequency, duration, false);


// wait for the note to play


delay(duration + duration / 16);


}


}

Posted

in

by

Tags:

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *