piezo reacting from splitting power to multiple things

I have two attiny85s that I'm powering with a single 3v battery.  One of these is connected to a piezo (so lights will flash when tapped).  However, the second one keeps affecting the power enough to set off the piezo reaction frequently without tapping.  I don't want to use two separate batteries.  How do I split the power between the two without them affecting each other? Thanks.

Posted by aliasjanedoe 4 years ago


In need of piezo

Anyone knows where I can get piezo? At my local electronics shop the aren't any. I am trying to look for them but won't appear, any guess where?

Posted by TobaTobias 6 years ago


how to make a piezo disk wiggle?

How would you make a piezo disk wiggle so you could see it move. Short story short i ultimately want to make a dual piezo cooling jet that GE had made (www.youtube.com/watch?v=Hm5fXj-hUpk)

Posted by vzfitch 5 years ago


Piezoelectricity Experiments. Help Needed!

I'm currently experimenting with piezoelectricity.And at the moment my experiment is limited to just a few piezo sparkers extracted from cigarette lighters.The sparker works with observable voltage spike on my multimeter. No voltage spike however when I use the tiny crystal (the size of a zippo flint) taken out from the sparker.I was trying to replicate this experiment (without the oscilloscope):Piezoelectric Rochelle SaltAnother thing, Would continuous vibration produce continuous voltage?It is known that piezo crystals produce high voltage, yet very low current. What are the options to increase the current? Would winding un-insulated copper wire around it (or any kind of contact with conductive metal) increase the current? Apart from lighter, what other surplus sources of piezoelectric crystals (i.e. quartz, PZT, Rochelle)? Can the crystal in RC toys, radios be used to generate electricity? Although there is the option to grow my own Rochelle salt, I'm not looking into it at the moment since it's going to take quite a while to grow.Thanks in advance!

Posted by gyromild 10 years ago


Piezo Disc

Can anyone enlighten me on the uses of the flat bi-metal piezo discs that have two leads (red/black) ? are these only good for more complex circuits or is there a way to make them create noise like a piezo buzzer? Thanks

Posted by chuckers 4 years ago


Piezo trigger Switch for a Virtual DrumKit

Can anyone help me to make a piezo trigger switch to use with a keybaord to trigger the samples from my pc? I got the idea from here https://www.instructables.com/id/WORLDS-CHEAPEST-VIRTUAL-DRUM-at-10-Rs500-us/ (see step 6) Thanks.

Posted by joeyjerry 4 years ago


Piezo trigger Switch for a Virtual DrumKit

Can anyone help me to make a piezo trigger switch to use with a keybaord to trigger the samples from my pc? I got the idea from here https://www.instructables.com/id/WORLDS-CHEAPEST-VIRTUAL-DRUM-at-10-Rs500-us/ (see step 6) Thanks.

Posted by joeyjerry 4 years ago


Piezo trigger Switch for a Virtual DrumKit

Can anyone help me to make a piezo trigger switch to use with a keybaord to trigger the samples from my pc? I got the idea from here https://www.instructables.com/id/WORLDS-CHEAPEST-VIRTUAL-DRUM-at-10-Rs500-us/ (see step 6) Thanks.

Posted by joeyjerry 4 years ago


ultrasonic

HI, Guys .. i have only little question : IS there any way how to made cheep ( or from house-hold items) piezo ultrasonic transducer? thanks for answer :)

Posted by insurgent 4 years ago


piezos

What is a good place to find piezos? I know I can find them in some old computers and cheap toys with "sirens" in them. What other devices readily have piezos installed? (....and please spare me the sarcastic answers about finding them at Radioshack)

Posted by randofo 10 years ago


Using a Piezo to trigger lights?

Hey all. What I am trying to construct is some kind of circuit that will trigger an LED when a piezo is tapped. The reason I would like to create this apparatus is to trigger lights using acoustic drums for my band's live show. I would like a light to go off every time a drum is hit and I figured that using a piezo would be the best way to do this. Any help that anyone could offer in this would be greatly appreciated. Thanks again. P.S. I found this diagram for a piezo switch but I am unsure as how i could use this or even how to make it in the first place. I am very new to electronics.

Posted by cimz 7 years ago


Tutorial: LCD Thermometer with optional Alarm

I created this Arduino tutorial. I hope somebody finds it helpful! Feel free to post any comments or suggestions. http://wellsb.com/post/1328196426/arduino-lcd-thermometer-with-optional-alarm

Posted by 5m0k3 8 years ago


Using a piezo as a vibration sensor

Hi, I'm thinking of getting a piezo sensor like this one http://www.meas-spec.com/product/t_product.aspx?id=2474 to measure the frequency of the vibrations of any surface I attach it to, using a micro like an arduino or pic. However I haven't come up the circuitry to make this happen, any ideas? Thanks

Posted by Arellano 6 years ago


Light Up Snare

Would it be possible to assemble a circuit using a piezo sensor and a string of LEDs so that a snare lights up when hit? My knowledge of stuff like this is extremely limited (read: non-existent) so any help would be appreciated! Also, if my idea is useless, it'd be great if other ways of doing this were discussed. Thanks!

Posted by clairey 10 years ago


Arduino knock sensor with a twist

Hey there! I live in a dorm and there's no preinstalled doorbell so i thought i'd do something funkier. I've used the stock Arduino Knock code and modified it a bit so agitating the piezo will make a connected buzzer beep. The problem is that while the entire setup is working, the buzzer itself is very very quiet. With a pure tone making script the buzzer will make a loud BEEEP, but combined with the knock code it's extremely quiet. I'm new to Arduino's so please bear with me when i show my code (most is copy/paste to fit): /* Knock Sensor      This sketch reads a piezo element to detect a knocking sound.    It reads an analog pin and compares the result to a set threshold.    If the result is greater than the threshold, it writes    "knock" to the serial port, and toggles the LED on pin 13.      The circuit:     * + connection of the piezo attached to analog in 0     * - connection of the piezo attached to ground     * 1-megohm resistor attached from analog in 0 to ground    http://www.arduino.cc/en/Tutorial/Knock       created 25 Mar 2007    by David Cuartielles    modified 30 Jun 2009    by Tom Igoe  */   // these constants won't change: int speakerPin = 9; int ledpin = 13; const int ledPin = 12;      // led connected to digital pin 13 const int knockSensor = 1;  // the piezo is connected to analog pin 0 const int threshold = 10;  // threshold value to decide when the detected sound is a knock or not // these variables will change: int sensorReading = 0;      // variable to store the value read from the sensor pin int ledState = LOW;         // variable used to store the last LED status, to toggle the light void setup() {  pinMode(ledPin, OUTPUT); // declare the ledPin as as OUTPUT } void loop() {   // read the sensor and store it in the variable sensorReading:   sensorReading = analogRead(knockSensor);        // if the sensor reading is greater than the threshold:   if (sensorReading >= threshold) {     // toggle the status of the ledPin:     ledState = !ledState;       // update the LED pin itself:            digitalWrite(ledPin, ledState);     buzz(9, 2500, 500); // buzz the buzzer on pin 4 at 2500Hz for 1000 milliseconds   delay(100);    }     // delay to avoid overloading the serial port buffer } void buzz(int targetPin, long frequency, long length) {   long delayValue = 1000000/frequency/2; // calculate the delay value between transitions   //// 1 second's worth of microseconds, divided by the frequency, then split in half since   //// there are two phases to each cycle   long numCycles = frequency * length/ 1000; // calculate the number of cycles for proper timing   //// multiply frequency, which is really cycles per second, by the number of seconds to   //// get the total number of cycles to produce  for (long i=0; i < numCycles; i++){ // for the calculated length of time...     digitalWrite(targetPin,HIGH); // write the buzzer pin high to push out the diaphram     delayMicroseconds(delayValue); // wait for the calculated delay value     digitalWrite(targetPin,LOW); // write the buzzer pin low to pull back the diaphram     delayMicroseconds(delayValue); // wait againf or the calculated delay value   } } If i get this working i'll see if i can make an instructable out of it (and make a "secret knock identifier"). I ended up using this code: [url]http://vimeo.com/groups/arduinoprojects/videos/1940394[/url] which works (code can be found by following the links) And it works! I'm still wondering what was wrong with my (pasted) code though.

Posted by Eirinn 9 years ago


Measuring the piezo transducer with oscilloscope

Hi, I am conecting a piezo disc as a microphone to pick up vibrations. .The problemm is when I measure the signal with osciloscope I am getting a messy and modified one with many noise  If I am measuring it with PC oscilloscope (threw the sound card mic input) I am gatting a clean desirable signal What is the true signal and what I am doing bad with the oscilloscope. Thanks! Anna

Posted by AnnaL3 3 years ago


Piezo Sensor to Detect Vibration Through Glass

Hello,  I am working on a project where I need to detect vibration through glass panes or on the surface of a window. I am currently planning to use a Piezo sensor with Arduino to detect and record different tests. I want to make sure that the senor is able to pick up the vibrations and not be too sensitive and pick up other things around it. I may need to tune the sensitivity. Besides the Piezo sensor I was also looking at the Parallax 605-00004 Piezo Film sensor (any advice on which one to use is appreciated.) If there are any other sensors that anyone may know that could work in this case, please let me know. I don't have a clear vision but any help to find out how I would go about this is greatly appreciated.  Thanks for the help

Posted by surajshah1 1 year ago


Piezo analogue sound

Hi all. I am a newbie and this is my first post so i might be barking up the wrong tree here. Would it be possible to use one of those small piezo-ceramic speakers to play sound e.g. from an mp3 player headphone jack? i am not looking for great quality sound, only voice quality, but i needs to be fairly loud. Many Thanks, Bob

Posted by saiorse44 11 years ago


Piezo Triggered LED lighting with a twist!

Hi There are already a few threads and topics on this site explaining how to hook up a piezo triggered light strip, however I'm looking to build a custom drum kit with particular lighting system and i can't find the info I need to build it. Inside the drums I want a constant, static colour of my choice on the led strip (e.g. blue) and then the piezo trigger triggers that LED strip to to different colour (e.g. red) for a quick flash and then back to blue. I would also like to have control over which colour combinations I use, so if i want yellow drums with green flashes, i would hopefully be able change that with a remote. Is there a circuit or a mod of an existing circuit that will handle my needs? Cheers, Owen

Posted by oesheppard 3 years ago


Arduino Gas Sensors

We are making an arduino-based gas detector that uses a combination of LED lights and a beeping piezo element to alert users to different levels of carbon monoxide in the air. We are having some difficulty in coding to have all the elements work together properly. What are some examples of arduino coding that can have a gas sensor chip, LEDs, and a piezo working together with a set of triggers, like the different concentrations of gas?

Posted by hthnc-student 6 years ago


Annoy-A-Thing 2.0 Development

Annoy-A-Thing made by let_it_out_org.After seeing some interest in developing a second iteration of the device, I thought it could be a good idea to start a forum thread for the development.I think the device should ; Beep at random (or kind of) interval, Use a 555 or a 556 timer, and it should not be powered by a microcontroller.

Posted by lordofthedonuts 9 years ago


Arduino Help

I have found a lot of cool codes online such as pov and piezo element projects, but I have no idea how to put the code into the environment! Any help? (I mean like can I copy and paste it or something?)

Posted by fallenspirit123 9 years ago


banger for re-enactment

I need to make a small banger that i can fit into a a re-enactmen rifle (or near it) that will reliably bang on command. i am thinking something run on butane with a piezo sparker..any ideas?

Posted by maninamousesuit 7 years ago


Vibrotactile Device

Hi, I am trying to build a portable device that takes vocal vibrations (from a piezo mic attached to the throat) and outputs them as tactile vibrations elsewhere (say at the sternum). I've found and built simple circuits for preamps that run off 9V like this one (https://www.instructables.com/id/Make-a-Simple-Audio-Amplifier/?ALLSTEPS) but I'm struggling to work out how I can connect and power a vibrating device (e.g. another piezo mic) for the output.  I guess I will need to include a low pass filter too to prevent the device creating audible output (I just want low frequency tactile vibration). I've seen a similar project here https://www.instructables.com/id/Representing-audio-through-vibration-with-Arduino/?ALLSTEPS but it's using an arduino and I feel like that's unnecessary for my purposes.  Any ideas really appreciated, Oli

Posted by ocheadle 4 years ago


Which Processor?

Hello everyone. I'm new here and I have a quick question about processors. I'm working on a project that requires a device to take inputs piezo buzzer elements and trigger an LED. The catch is I need a programmable chip so I can have pre-set outputs on the LEDs. I'd need something that can be rewritten (like an EEPROM) I've been thinking abuot using a PIC or a BASIC Stamp but I'd though I'd do a bit of research first.

Posted by mrpaps 11 years ago


Sensor to eventually measure weight ( up to 250 lbs)

Hi everyone, I am stuck trying to find a method or sensor to do what I want. Basically, I am trying to make a cheap flat weight scale- light weight and portable; thinner than using load cell sensors. I was hoping for a flat compression fabric or piezo resistive pressure sensor, but have not found what I was looking for. Does something like this exist?

Posted by appl314 7 years ago


How To Use the Alarm from an Alarm Clock in Something Else?

I wanted to make an alarm type thingy, ad I want to use the alarm from an alarm clock. I don't know how though, I tried connecting a cell to the wires that were already on the alarm, but it won't work. I think it's one of those piezo-electric crystal thingies. And I know I have to have pressure on it to work. How exactly would I use it?

Posted by Aeshir 11 years ago


DC buzzer/noisemaker that doesn’t use a transistor?

I’ve got some nice homemade field phones I made out of old carbon microphone handsets.  I’ve currently got DC piezo buzzers for ringers (which have transistors in them). I want to them to be able to survive an EMP, so I don’t want to use transistors. Is there anything I can use for a DC buzzer/noisemaker that doesn’t need AC power, or a transistor?   The voltage of the phones is 1.5v - 3v dc    

Posted by instrucables360 2 years ago


Dirt Cheap Acoustic Guitar Pickup

Hi I am concerned about the health and safety aspects of the instructable of "Dirt Cheap Acoustic Guitar Pickup by Xuthal". The project encourages people to take apart a smoke detector to obtain a piezo sounder. However no warning at all is given by the author that there may be radioactive material in the device, or how to recognise it and how to deal with it. I tried to post a warning on the article but for some reason it hasn't worked. I could not see how to flag up the item so I am posting here. Whilst the manufacturers of smoke alarms play down the dangers of Americium 241 dioxide (the radioactive material), they would most certainly not condone opening up a smoke detector sensor. Am O2 will most likely pass straight through the gut due to its insolubility, so your readers are probably safe from ingesting it. However, if the source is fractured into dust particles, it could be inhaled and will lodge in the lung for a long time. Being an alpha emitter the Am241 will very likely end up causing a lung cancer. I think this instructable is highly irresponsible and should be removed. In any case the item taken from the smoke detector, a piezo transducer, is readily available from any hobby electronics supplier and costs less than the battery to power the detector in the first place!

Posted by TCSC47 3 years ago


Competition Shooting Timer made with Arduino

I have only begun to use Arduino in the last few months, and my skill set is still somewhat lacking.  I can easily build the circuit that I need, however programing is still difficult at this point.  Especially trying to write my own program from scratch. I am looking for help to make a Competitive Shooting Timer for IDPA competitions(international defensive pistol association).  In my head it should use a piezo speaker as a microphone on a digital input, have a couple LED's for currently working and ready status, an LCD screen that shows the time lapsed since the first shot occurred to the hundredths of a second, and a push-button to stop the timer. Any help would be greatly appreciated!!

Posted by gothiway 3 years ago


picaxe sensitivitį

Hi there instructables, recently I have bought a picaxe starter kit, soldered it and stuff, played with some code and leds, but now I want to make a time control, so I bought a cheepo alarm clock, desolder the piezo beeper and extended the wires so I can conect them to my picaxe, turns out its too sensitive, the pin I've set to input piks up heat fom my fingers about a centimeter away, breath too, I think it picks up grounding as a signal too, does it ment to be that sensitive or have I messed something up with soldering or the code?  heres the code I used  main: if pinc.4 = 1 then goto led goto main led: high c.1 pause 500 low c.1 pause 100 goto main

Posted by batonas 4 years ago


Need a schematic design for a simple circuit.

I was wondering if anyone here could help me design a particular circuit. The "device" would need a single button. When said button is pressed a buzzing sound would occur ( kinda like in game shows, you know that wrong answer sound?) then wait for five minutes and automatically buzz again by its self. Press once (BUZZ) wait 5 minutes buzzes again without the need to press again. I am perfectly capable of reading schematics and building prototype circuits. I just have no "nack" for design as of yet. Any help on this issue would be greatly appreciated. Thank you for reading my post. PS: I am a little rusty on some of the symbols, therefore a legend would be great.

Posted by ClaynEva 3 years ago


Hacking An Alarm Clock

My sister (yes, the one for whom I made earrings) wants me to modify an alarm clock to run a small electronic device when it goes off. Preliminary research has given me two methods:1) A digital clock with a 555 timer circuitIn this setup, a 555 timer circuit is used to translate the signal to an alarm speaker/piezo disk into a relay. When the clock goes off, the relay clicks, and any electrical device that is run through the relay has power.2) An analog clock with a transistor amplifierIn this version, the analog clock seems to just have a straight DC output to the alarm. The transistor is used to amplify the DC to drive the motor of a fire bell.Which of these would be easier to implement? The device I am supposed to use runs off of 3VDC, so I was just going to run the power line through the relay or through the transformer.

Posted by CameronSS 10 years ago


Open Software for Fashion Prototyping

This has got to be the most exciting thing to come down wearable technology pike! It's a FREE downloadable book about Arduino boards (both "standard" and LilyPad), conductive fabric, resistive thread, soft buttons, LEDs and more!! The eBook is split into three parts covering the basics of hardware, software and the use of the Arduino IDE (Integrated Development Environment) in the first part. Part two give examples of using eTextile materials and the Arduino to make first cool projects involving LEDs, Piezo speaker and, the Digital and analog zipper.The third part is dedicated to show how to write programs for the Arduino platform. This all might sound very technical for fashion/clothing designer but dont be afraid, it's easily explained and covers just what's needed for wearable electronics (and not for building an new space station).I cannot wait to get started with this eBook! Finally, all the mysteries I had to ask others to program for me, unravelled! pun intendedDownload yours today. NOW! at Open Softwear

Posted by scoochmaroo 9 years ago


Turn passive speakers into active speakers?

Hi, I finally got around to starting the Altoids Tin Guitar but I have a problem: I have no amp. And an electric guitar is kind of useless without an amp. I figured I could use some old computer speakers but I realized that they are not powered speakers. Is there any way to turn passive speakers into active speakers? Or at the very least is there any software I can download that will let me hear the guitar on my computer as I play? I've tested the piezo (attatched to the 1/8" jack with an audio cable.. I forgot what you call it, but it's the kind that has two plugs) by plugging it into the mic jack for my computer and holding it near my acousic guitar while I strum. I can record audio just fine but I can't hear as I play. Is there any software that would let me do that? (A demo is fine with me.)

Posted by teh darkcloud 9 years ago


What to buy if your a beginner

Hello, I'm 13 and I want to get started in electronics. I know how to solder and read basic schematics and I have two of those 200 in 1 electronics sets. I am about to make an order for some components from www.bitsbox.co.uk.This is what I have so far, anything you would add or remove? (I couldn't easily get the quantities)pp3 battery clips2 x AA Battery Holder3 x AA Battery Holder11 wire single core bundle1uF 50V Electrolytic Radial100uF 25V Electrolytic Radial220uF 16V Electrolytic Radial22uF 50V Electrolytic Radial25-way PCB D-connector PlugPrototyping breadboard 80x60Watch crystal1N4001 Rectifier Diode 1A 50VStripboard 95x64White LED 5mm 30000mcd24V 16A SPST K4TA24 RelayPiezo Transducer with Flying Leads7805 voltage regulator (to get a steady 5v from a wall wart for the breadboard)NE555 timer IC2N3904 NPN transistorBC213 TransistorATTiny2313-20PUlm386 op-ampStandard Toggle SPSTupdates:I have a multimeter, resistors and LEDs and I am buildng an attiny 2313 programmer as well as adding to my collection.

Posted by josh92176 11 years ago


Outdoor listening installations

Would appreciate some advice on this project.  I'm putting together a proposal for a series of outdoor sound installations in a nature park.  a couple of the installations will be places where you can plug in headphones to listen to certain sounds captured live from a microphone in an interesting place- for example a hydrophone in a pond.  The plan is that the mic will be hooked up to 3.5 jack sockets and listerners will be able to plug in their own headphones.  Now obviously there needs to be some amplification because the mic signal level will be far too quiet to hear on headphones. I need a power amp that will be powered through a solar panel.  My question is, shall I just use a headphone amp, like the Behringer ha400 or make my own power amp circuit? I need to be able to make everything sturdy and fit into a weather proof junction box to protect it from the elements. I have done some experiments with an LM386 power amp module but there was so much background noise and it didn't pick up the mic level at all (may have been a problem with the mic I was using,it was a crappy little lapel mic.- I did get a signal from a piezo disc but it was again really crackly and noisy.)  If it is best to build a circuit with a power amp module, could people make suggestions of ones that will sound good and clean, and work with stereo headphones.  Thanks a lot Ash

Posted by AshtonM4 2 years ago


Heartbeat Pulse+Speaker+555 timer

Hello all! I'm posting this idea that I have for making my wife a gift for our anniversary. I'm posting this in burning questions as my research time for this is rather limited as the whole project is to be a surprise. Here's what I aim to build... What I want to make is rather simple, I want to make a pulsating heartbeat sound through either a piezo speaker or just a small 2 inch or smaller speaker. The more compact the better as I plan to integrate this into the other half of my project. The problem is im not very familiar with the 555 timer, I normally don't use them in my projects as I try to work with AC most of the time. But that's another topic. So anyways, my idea is to set the duty cycle low so it's 3 quick pulses and then about a second of silence. I imagine programming in Arduino would be easier but therein lies the problem: I do not know how to program and every Arduino I have is fried. (I make good use out of my components!) This is when I turn to the community and sincerely ask for your help in making this possible. Someone who is more familiar and can quickly and conveniently answer this is obviously more then welcome! This is where I plan on getting most of my research done in my off time. Any help is greatly appreciated. If further explanation is needed please do not hesitate to ask. :-)

Posted by 49percentGood 5 years ago


Small proximity sensors with short range and alarm either IR or RFID

I would like to make two key fob sized units that if brought within ~20cm of each other would sound an alarm from one of the units. I've seen a pair of key fob sized RDIF alarm tags that sound an alarm in one if moved more than ~10m apart. They sell for ~$50 US but I need something that accomplishes just the opposite from this device. I want to keep two pets away from each other (one bullies the other) and such a device would I believe accomplish this task. It seems like it should be relatively simple to design but I'm an artist and machinist and know little about electronics. I purchased a book entitled Practical Electronics for Inventors that has given me some knowledge about the basics of transformers, relays, capacitors, resisters, etc. but nothing on IR or RFID transmitters/receivers. Everything I read about RDIF is geared towards one stationary reader (or large hand-held unit) and one or more transmitters. I made one collar with an IR receiver from an R/C car and a small piezo alarm that would sound when I pushed a button on a remote. This works but only if I'm in the same room with the offending animal. I need something that works when I'm away or the animals are upstairs or in another part of the house. They are indoor only pets so the device need not be weather-proof. Anyone with knowledge of such things want to lend me a hand?

Posted by bigdaddyjt 8 years ago


Super Complicated Code (playing music and moving servos at the same time)

Hey all! I'm trying to make a present for a friend and it's not working out at all :( (due this tuesday). So I ripped up a teddy bear, put some servos in it's arm, and a speaker in it's stomach. I'm trying to use my arduino uno to play tunes over the speaker while make it's arms wobble. My problem is that the song contains delays for getting the notes on beat, which means that I can't have other things going on at once. Is there anything else I can do? I'm stuck with just making it's arms move, then having the tunes play while the arms are still, then having them move again.  Now I did figure out a method to get the servos to move without using a delay function. That's at the very bottom void move(); I know it's probably about the worst way to make servos move slowly without delay but it works. I'm not worried about that. I'm just wondering how am I going to play music and have the servos move at the same time? Thanks! Here's my code.  int speakerPin = 5; int buttonPin = 6; int buttonPress; int buttonCount;  int leds = 13; #include int servospeed(100); Servo servoleft; Servo servoright; int val = 20; int val2; boolean state = true; unsigned long currentMillis; unsigned long previousMillis; int songLength1 = 7000; int songLength2; /*****************************************************************************************************/ /* Smaller value -> all tunes play faster; bigger -> slower. Recommend you don't change this, but instead use playTune() to pass different beatLength values to parseTune() for different songs */ const int beatLength = 50; // Generate a tone by passing a square wave of a certain period to the piezo void playTone(int tone, int duration) {   for (long i = 0; i < duration * 1000L; i += tone * 2) {     digitalWrite(speakerPin, HIGH);     delayMicroseconds(tone);     digitalWrite(speakerPin, LOW);     delayMicroseconds(tone);   } } /* This works out what period, in microseconds, to use for the square wave for a given note. To calculate these, p = ((1 / freq) * 1,000,000) / 2. We divide by 2 because the signal will be HIGH for p microseconds and then LOW for p microseconds. Frequencies for the notes obtained from http://www.phy.mtu.edu/~suits/notefreqs.html The range defined below covers 2 octaves from C4 (middle C, or 261.63Hz) to B5 (987.77Hz). Feel free to modify. */ void playNote(char note, int duration, boolean sharp) {   char names[] = {     'c', 'd', 'e', 'f', 'g', 'a', 'b', 'C', 'D', 'E', 'F', 'G', 'A', 'B'         };   int tones[] = {     1915, 1700, 1519, 1432, 1275, 1136, 1014, 956, 851, 758, 716, 636, 568, 506         };   // these are the "sharp" versions of each note e.g. the first value is for "c#"   char names_sharp[] = {     'c', 'd', 'f', 'g', 'a', 'C', 'D', 'F', 'G', 'A'         };   int tones_sharp[] = {     1804, 1607, 1351, 1204, 1073, 902, 804, 676, 602, 536         };   // play the tone corresponding to the note name   if (sharp == false) {     for (int i = 0; i < 14; i++) {       if (names[i] == note) {         playTone(tones[i], duration);       }     }   }   else {     for (int i = 0; i < 10; i++) {       if (names_sharp[i] == note) {         playTone(tones_sharp[i], duration);       }     }   } } /* Take a string representing a tune and parse it to play the notes through the piezo. Parameters: char notes[]: a string that represents the notes of the song. The grammar for parsing the string is described at the top of this file. int beatLength: changes the tempo. Smaller value -> quicker; bigger -> slower boolean loopSong: if true, the song will loop indefinitely (until you press the microswitch) */ void parseTune(char notes[], int beatLength, boolean loopSong) {   boolean play = true;   // 1 iteration of this loop == 1 note played   for (int i = 0; notes[i] != '.' && play == true; i++) { // stop iteration if '.' is the next char       if (notes[i] == ',') { // ',' signifies a rest       // Look at the number (max. 2 digits) following from the ',' to work out the duration of the rest       char len[3];       int count = 0;       while (notes[i+1] >= '0' && notes[i+1] <= '9' && count < 2) {         len[count] = notes[i+1];         count++;         i++;       }       len[count] = '\0';       int duration = atoi(len);       delay(duration * beatLength); // rest duration     }     else { // play the next note, represented by a series of characters e.g. 'c4', 'a#12'       char note = notes[i];       boolean sharp;       // if the next character is a '#' then we must make the note a sharp       if (notes[i+1] == '#') {         i++;         sharp = true;       }       else {         sharp = false;       }       // Look at the number (max. 2 digits) following from the note name to work out the note duration       char len[3];       int count = 0;       while (notes[i+1] >= '0' && notes[i+1] <= '9' && count < 2) {         len[count] = notes[i+1];         count++;         i++;       }       len[count] = '\0';       int duration = atoi(len);       playNote(note, duration * beatLength, sharp);     }     delay(beatLength / 2); // pause between notes   } } // Write your tunes in here using the grammar described at the top of this file. Can have up to 4 tunes. void song1() {   char notes[] = "d4g4g2a2g2f#2e4c4e4a4a2b2a2g2f#4d4f#4b4b2C2b2a2g4e4d2d2e4a4f#4g8,8.";   parseTune(notes, beatLength * 1.25, false); } void song2() {   char notes[] = "b4b4b8b4b4b8b4D4g6a2b12,4C4C4C6C2C4b4b4b2b2b4a4a4b4a8D8b4b4b8b4b4b8b4D4g6a2b12,4,C4C4C6C2C4b4b4b2b2D4D4C4a4g12,8.";   parseTune(notes, beatLength, false); } /**********************************************************************************************************/ void setup() {   pinMode(speakerPin, OUTPUT);   pinMode(buttonPin, INPUT);   pinMode(leds, OUTPUT);   servoleft.attach(8);   servoright.attach(7);   servoleft.write(30);   servoright.write(120);   Serial.begin(9600); } void loop() {   currentMillis = millis();   move();   song1(); } /**************************************/ void move() {   if (currentMillis - previousMillis > 50)   {     if ( val <= 60 && state == true)     {       val++;       servoleft.write(val);       val2 = map(val, 20, 60, 80, 120);       servoright.write(val2);       if (val >= 60)       {         state = false;       }     } //     if (val >= 20 && state == false)     {       val--;       servoleft.write(val);       val2 = map(val, 60, 20, 120, 80);       servoright.write(val2);       if (val <= 20)       {         state = true;       }     }//     previousMillis = currentMillis;     Serial.println(val);   } // if millis }

Posted by HavocRC 3 years ago


Arduino 12V Car-alarm with PIR sensor and remote control - expertise needed. :-)

Hi all, This is my first "big" Arduino project and my first fritzing, so please bear with me. :-) Goal: - Build the cheapest possible car alarm system with a loud siren - It should be possible to activate/deactivate the alarm with a remote control. - The alarm will once activated, sense any motion in the car (if someone breaks a window and tries to steal anything) and set of the alarm. - The system should not drain the car battery so it should draw a minimum of power. I've managed to build the first few things, but some vital steps are still needed and I hope you can help me sort these out. Components used so far: Arduino Pro Mini - TIP122 transistor - 2.2KOhm resistor - 1N4002 diode - Mini piezo siren (I used a 107dB siren with an operating voltage of 6-15Vdc and current consumption of 140mA) - Breadboard - Lots of wires I'm currently waiting for my PIR sensor to arrive together with the RF receiver/transmitter module, so for now I've added a basic switch to act as the PIR sensor and another for the RF module (activate/deactivate). The components I'm waiting for are: - An RF module that I need to order once i find the right one. - http://www.ebay.com/itm/261041100836?_trksid=p2060... Questions that still remain and that I hope you can help me with: 1. The arduino should be powered by the cars 12V battery, however I've read that the car battery must be regulated as it delivers anywhere from 12 - 16V. I could connect it directly to RAW but in case the battery peaks above 16V i risk damaging the Arduino. I'm very unsure as to how I do this regulating best? One option could be to buy a "DC-DC step down converter - 4-35Vdc > 1,23-30Vdc" and set it to 5V, but maybe a more simple and/or cheaper solution exists? 2. Since the power consumption should be kept to a minimum, I plan to add the RF before the step down converter so the powering of the regulator (step down converter?) only happens if the alarm is activated from the remote. First question is: can I use a TIP120 for this and simply connect the RF to base, and the regulator to the collector? Second: In this case, the Arduino will be powered off the hard way by cutting power when deactivating the alarm from the remote - can the arduino take that in the long run? and finally, the RF receiver needs to get its power from somewhere, so what can I do here - is the best thing to use a 12V RF module instead of the Arduino 5V RF module or can this be solved some other way? 3. Any good ideas for minimizing power consumption? 4. Anything I can do to further improve the design? :-) I'll update this post as I progress with the project including a more detailed step guide to how to implement this and the source code I'm using. Instructables arduino posts and commets have helped me a lot during over the past few weeks working with Arduino so I hope you can help me reach the finish line with this project. Br. Jakob

Posted by Zyb3r 2 years ago


I need help with this code

Hello, I'm creating a PIR Sensor Alarm with Arduino. I'm using Arduino Uno, PIR Sensor, Breadboard, LED, Piezo Buzzer, TTL JPEG Camera, SD Card and SD Card Module (Breakout Board) I tested my code and it didn't give me any errors. However, the LED and the Buzzer are on all the time, my idea is to have them on once the PIR Sensor detects motions. I know that I'm having problem with the code. Therefore, I'd appreciate it so much if someone could find out which parts of my code should I change. ---------------------------- #include #include #include int pirPin = 7; int ledPin = 8;                // choose the pin for the LED int pinSpeaker = 10;           //Set up a speaker on a PWM pin (digital 9, 10, or 11) int minSecsBetweenEmails = 60; // 1 min long lastSend = -minSecsBetweenEmails * 1000l; byte ZERO = 0x00; byte incomingbyte; SoftwareSerial mySerial(2,3);          // Set Arduino pin 2 and 3 as softserial long int a=0x0000,j=0,k=0,count=0,i=0; uint8_t MH,ML; boolean EndFlag=0; File  myFile; void SendResetCmd(); void SetBaudRateCmd(); void SetImageSizeCmd(); void SendTakePhotoCmd(); void SendReadDataCmd(); void StopTakePhotoCmd(); void setup() {   pinMode(pirPin, INPUT);   pinMode(ledPin, OUTPUT);      // declare LED as output   pinMode(pinSpeaker, OUTPUT);   Serial.begin(9600);   Serial.begin(115200); while (!Serial) { ; // wait for serial port to connect. Needed for Leonardo only } mySerial.begin(38400); Serial.print("Initializing SD card..."); // On the Ethernet Shield, CS is pin 4. It's set as an output by default. // Note that even if it's not used as the CS pin, the hardware SS pin // (10 on most Arduino boards, 53 on the Mega) must be left as an output // or the SD library functions will not work. pinMode(10, OUTPUT); if (!SD.begin(10)) { Serial.println("initialization failed!"); return; } Serial.println("initialization done."); } void loop() {   long now = millis();   if (digitalRead(pirPin) == HIGH)   {     digitalWrite(ledPin, HIGH);  // turn LED ON     playTone(300, 160);     delay(150);     if (now > (lastSend + minSecsBetweenEmails * 1000l))     {       Serial.println("MOVEMENT");       lastSend = now;     }     else     {       digitalWrite(ledPin, LOW); // turn LED OFF       playTone(0, 0);       delay(300);         Serial.println("Too soon");     }   }   delay(300); } // duration in mSecs, frequency in hertz void playTone(long duration, int freq) {     duration *= 1000;     int period = (1.0 / freq) * 1000000;     long elapsed_time = 0;     while (elapsed_time < duration) {         digitalWrite(pinSpeaker,HIGH);         delayMicroseconds(period / 2);         digitalWrite(pinSpeaker, LOW);         delayMicroseconds(period / 2);         elapsed_time += (period);     } byte a[32]; int ii; SendResetCmd(); delay(4000);                            //Wait 2-3 second to send take picture command SendTakePhotoCmd(); while(mySerial.available()>0) {   incomingbyte=mySerial.read(); } myFile = SD.open("pic.jpg", FILE_WRITE); //The file name should not be too long while(!EndFlag) {   j=0;   k=0;   count=0;   SendReadDataCmd();   delay(200); //250 for regular   while(mySerial.available()>0)   {      incomingbyte=mySerial.read();     k++;     if((k>5)&&(j<32)&&(!EndFlag))     {      a[j]=incomingbyte;      if((a[j-1]==0xFF)&&(a[j]==0xD9))     //tell if the picture is finished      EndFlag=1;      j++;     count++;     }   } for(j=0;j { if(a[j]<0x10) Serial.print("0"); Serial.print(a[j],HEX);           // observe the image through serial port Serial.print(" "); } for(ii=0; ii myFile.write(a[ii]); Serial.println(); i++; } myFile.close(); Serial.print("Finished writing data to file"); while(1); } void SendResetCmd() { mySerial.write(0x56); mySerial.write(ZERO); mySerial.write(0x26); mySerial.write(ZERO); } void SetImageSizeCmd() { mySerial.write(0x56); mySerial.write(ZERO); mySerial.write(0x31); mySerial.write(0x05); mySerial.write(0x04); mySerial.write(0x01); mySerial.write(ZERO); mySerial.write(0x19); mySerial.write(0x11); } void SetBaudRateCmd() { mySerial.write(0x56); mySerial.write(ZERO); mySerial.write(0x24); mySerial.write(0x03); mySerial.write(0x01); mySerial.write(0x2A); mySerial.write(0xC8); } void SendTakePhotoCmd() { mySerial.write(0x56); mySerial.write(ZERO); mySerial.write(0x36); mySerial.write(0x01); mySerial.write(ZERO); } void SendReadDataCmd() { MH=a/0x100; ML=a%0x100; mySerial.write(0x56); mySerial.write(ZERO); mySerial.write(0x32); mySerial.write(0x0c); mySerial.write(ZERO); mySerial.write(0x0a); mySerial.write(ZERO); mySerial.write(ZERO); mySerial.write(MH); mySerial.write(ML); mySerial.write(ZERO); mySerial.write(ZERO); mySerial.write(ZERO); mySerial.write(0x20); mySerial.write(ZERO); mySerial.write(0x0a); a+=0x20; } void StopTakePhotoCmd() { mySerial.write(0x56); mySerial.write(ZERO); mySerial.write(0x36); mySerial.write(0x01); mySerial.write(0x03); } --------------------------- Thanks a lot!

Posted by fhussein1 4 years ago