{"id":38,"date":"2015-01-22T01:35:42","date_gmt":"2015-01-22T01:35:42","guid":{"rendered":"http:\/\/www.caiodemarco.com.br\/atelie\/?p=38"},"modified":"2015-11-24T04:40:18","modified_gmt":"2015-11-24T07:40:18","slug":"bike-sirene","status":"publish","type":"post","link":"http:\/\/www.ateliehacker.com\/en\/bike-sirene\/","title":{"rendered":"Bike&#8217;s Siren"},"content":{"rendered":"<p><a href=\"https:\/\/i0.wp.com\/www.ateliehacker.com\/wp-content\/uploads\/2014\/02\/Arduino-Atelie-Hacker7.png\"><img data-attachment-id=\"320\" data-permalink=\"http:\/\/www.ateliehacker.com\/en\/bike-sirene\/arduino-atelie-hacker-10\/\" data-orig-file=\"https:\/\/i0.wp.com\/www.ateliehacker.com\/wp-content\/uploads\/2014\/02\/Arduino-Atelie-Hacker7.png?fit=748%2C120\" data-orig-size=\"748,120\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"Arduino Atelie Hacker\" data-image-description=\"\" data-medium-file=\"https:\/\/i0.wp.com\/www.ateliehacker.com\/wp-content\/uploads\/2014\/02\/Arduino-Atelie-Hacker7.png?fit=300%2C48\" data-large-file=\"https:\/\/i0.wp.com\/www.ateliehacker.com\/wp-content\/uploads\/2014\/02\/Arduino-Atelie-Hacker7.png?fit=700%2C112\" loading=\"lazy\" class=\"alignnone size-full wp-image-320\" src=\"https:\/\/i0.wp.com\/www.ateliehacker.com\/wp-content\/uploads\/2014\/02\/Arduino-Atelie-Hacker7.png?resize=700%2C112\" alt=\"Arduino Atelie Hacker\" width=\"700\" height=\"112\" srcset=\"https:\/\/i0.wp.com\/www.ateliehacker.com\/wp-content\/uploads\/2014\/02\/Arduino-Atelie-Hacker7.png?w=748 748w, https:\/\/i0.wp.com\/www.ateliehacker.com\/wp-content\/uploads\/2014\/02\/Arduino-Atelie-Hacker7.png?resize=300%2C48 300w\" sizes=\"(max-width: 700px) 100vw, 700px\" data-recalc-dims=\"1\" \/><\/a><\/p>\n<p>Sounder bike is perfect to the safety of the cyclist, because when you ride on the street a lot of times you have the Necessity of warning: &#8220;Look, I&#8217;m here!&#8221;. Whether for a car, bus or even pedestrian, we have to stay alert and make us visible. With this project you can build a siren to your bike with an Arduino. This prototype has a 12V buzzer with 3 different tones and LEDs that flash in the audio frequency.<\/p>\n<h2> Materials <\/ h2><br \/>\n1 Arduino<br \/>\n2 LEDs<br \/>\n3 Pushbutton<br \/>\n3 Resistors 10K Ohm<br \/>\n1 Resistors 2.2K Ohm<br \/>\n2 Resistors 220 Ohm<br \/>\n1 NPN 2222A<br \/>\n1 9V battery<br \/>\n1 9V battery socket<\/p>\n<p><iframe loading=\"lazy\" src=\"\/\/www.youtube.com\/embed\/ozG9ZyN8iI4\" width=\"640\" height=\"360\" frameborder=\"0\" allowfullscreen=\"allowfullscreen\"><\/iframe><\/p>\n<p>In this video the circuit used a buzzer 3V. Thereafter it was implemented using a buzzer 12V NPN transistor 2222A, as can be seen in the diagram below. So the sound gets louder, making it safe in certain situations where the volume is more critical.<\/p>\n<h2> Circuit <\/ h2><br \/>\n<a href=\"https:\/\/i1.wp.com\/www.ateliehacker.com\/wp-content\/uploads\/2014\/02\/Sirene-de-Bike_cc.png\"><img data-attachment-id=\"394\" data-permalink=\"http:\/\/www.ateliehacker.com\/en\/bike-sirene\/sirene-de-bike_cc\/\" data-orig-file=\"https:\/\/i1.wp.com\/www.ateliehacker.com\/wp-content\/uploads\/2014\/02\/Sirene-de-Bike_cc.png?fit=1803%2C1416\" data-orig-size=\"1803,1416\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"Sirene-de-Bike_cc\" data-image-description=\"\" data-medium-file=\"https:\/\/i1.wp.com\/www.ateliehacker.com\/wp-content\/uploads\/2014\/02\/Sirene-de-Bike_cc.png?fit=300%2C235\" data-large-file=\"https:\/\/i1.wp.com\/www.ateliehacker.com\/wp-content\/uploads\/2014\/02\/Sirene-de-Bike_cc.png?fit=700%2C550\" loading=\"lazy\" class=\"alignnone wp-image-394 \" src=\"https:\/\/i1.wp.com\/www.ateliehacker.com\/wp-content\/uploads\/2014\/02\/Sirene-de-Bike_cc.png?resize=700%2C550\" alt=\"Sirene-de-Bike_cc\" width=\"700\" height=\"550\" srcset=\"https:\/\/i1.wp.com\/www.ateliehacker.com\/wp-content\/uploads\/2014\/02\/Sirene-de-Bike_cc.png?resize=1024%2C804 1024w, https:\/\/i1.wp.com\/www.ateliehacker.com\/wp-content\/uploads\/2014\/02\/Sirene-de-Bike_cc.png?resize=300%2C235 300w, https:\/\/i1.wp.com\/www.ateliehacker.com\/wp-content\/uploads\/2014\/02\/Sirene-de-Bike_cc.png?w=1803 1803w, https:\/\/i1.wp.com\/www.ateliehacker.com\/wp-content\/uploads\/2014\/02\/Sirene-de-Bike_cc.png?w=1400 1400w\" sizes=\"(max-width: 700px) 100vw, 700px\" data-recalc-dims=\"1\" \/><\/a><\/p>\n<h2>Arduino Code<\/h2>\n<pre class=\"brush: arduino; collapse: true; light: false; title: Bike_Sirene.ino (Clique aqui para ver o c\u00f3digo); toolbar: true; notranslate\" title=\"Bike_Sirene.ino (Clique aqui para ver o c\u00f3digo)\">\r\n\/*\r\nSiren\r\n\r\nA configurable siren for Arduino, requires an 8-ohm speaker attached to\r\npin 8 and ground\r\n\r\n\/\/Copyright (c) 2012 Jeremy Fonte\r\n\/\/This code is released under the MIT license\r\n\/\/http:\/\/opensource.org\/licenses\/MIT\r\n*\/\r\n\r\nint pitchLow = 800; \/\/200\r\nint pitchHigh = 1600; \/\/1000\r\nint pitchStep = 10;\r\nint currentPitch;\r\n\r\nconst int speakerPin = 8;\r\n\r\nconst int button1Pin = 2; \/\/ the number of the pushbutton pin\r\nconst int button2Pin = 3;\r\nconst int button3Pin = 4;\r\n\r\nconst int led1Pin = 13;\r\nconst int led2Pin = 12;\r\n\r\n\/\/ variables will change:\r\nint button1State = 0; \/\/ variable for reading the pushbutton status\r\nint button2State = 0;\r\nint button3State = 0;\r\n\r\n\/\/\/LED\r\n\/\/ Variables will change:\r\nint ledState = LOW; \/\/ ledState used to set the LED\r\nlong previousMillis = 0; \/\/ will store last time LED was updated\r\n\r\n\/\/ the follow variables is a long because the time, measured in miliseconds,\r\n\/\/ will quickly become a bigger number than can be stored in an int.\r\n\/\/long interval = 500;\r\n\r\n\/\/\/Music\r\n#include &quot;pitches.h&quot;\r\n\r\nvoid playArp(int notes[]);\r\n\r\n\/\/ available chord to arpeggiate\r\n\/\/C major\r\nint c[] = {\r\nNOTE_C4, NOTE_E4,NOTE_G4, NOTE_C5, NOTE_E5};\r\n\r\n\/\/D minor\r\nint d[] = {\r\nNOTE_D4, NOTE_F4,NOTE_A4, NOTE_D5, NOTE_F5};\r\n\r\n\/\/E minor\r\nint e[] = {\r\nNOTE_E4, NOTE_G4,NOTE_B4, NOTE_E5, NOTE_G5};\r\n\r\n\/\/F major\r\nint f[] = {\r\nNOTE_F4, NOTE_A4,NOTE_C5, NOTE_F5, NOTE_A5};\r\n\r\n\/\/G major\r\nint g[] = {\r\nNOTE_G4, NOTE_B4,NOTE_D5, NOTE_G5, NOTE_B5};\r\n\r\n\/\/A minor\r\nint a[] = {\r\nNOTE_A4, NOTE_C5,NOTE_E5, NOTE_A5, NOTE_C6};\r\n\r\n\/\/B diminished\r\nint b[] = {\r\nNOTE_B4, NOTE_D5,NOTE_F5, NOTE_B5, NOTE_D6};\r\n\r\nvoid setup() {\r\ncurrentPitch = pitchLow;\r\n\r\n\/\/ initialize the LED pin as an output:\r\npinMode(led1Pin, OUTPUT);\r\npinMode(led2Pin, OUTPUT);\r\n\/\/ initialize the pushbutton pin as an input:\r\npinMode(button1Pin, INPUT);\r\npinMode(button2Pin, INPUT);\r\npinMode(button3Pin, INPUT);\r\n\r\n}\r\n\r\nvoid loop() {\r\n\r\n\/\/ read the state of the pushbutton value:\r\nbutton1State = digitalRead(button1Pin);\r\nbutton2State = digitalRead(button2Pin);\r\nbutton3State = digitalRead(button3Pin);\r\n\r\n\/\/ check if the pushbutton is pressed.\r\n\/\/ if it is, the buttonState is HIGH:\r\nif (button1State == HIGH) {\r\nsirene(0);\r\npiscaled(40);\r\n\r\n} else if (button2State == HIGH) {\r\nsirene(1);\r\npiscaled(100);\r\n\r\n} else if (button3State == HIGH) {\r\n\/\/ turn LED on:\r\n\/\/digitalWrite(ledPin, HIGH);\r\n\/\/delayTime = 3 ;\r\n\/\/sirene();\r\npiscaled(250);\r\nplayArp(b);\r\n\/\/playArp(c);\r\n\/\/playArp(b);\r\n\/\/playArp(a);\r\n\/\/playArp(e);\r\n\r\n} else {\r\n\/\/ turn LED off:\r\ndigitalWrite(led1Pin, LOW);\r\ndigitalWrite(led2Pin, LOW);\r\nnoTone(8);\r\n}\r\n\r\n}\r\n\r\nint sirene (int delayTime){\r\n\r\ntone(speakerPin, currentPitch, 10);\r\ncurrentPitch += pitchStep;\r\nif(currentPitch &gt;= pitchHigh) {\r\npitchStep = -pitchStep;\r\n}\r\nelse if(currentPitch &lt;= pitchLow) { pitchStep = -pitchStep; } delay(delayTime); } int piscaled (long velocidade){ \/\/ here is where you'd put code that needs to be running all the time. \/\/ check to see if it's time to blink the LED; that is, if the \/\/ difference between the current time and last time you blinked \/\/ the LED is bigger than the interval at which you want to \/\/ blink the LED. unsigned long currentMillis = millis(); if(currentMillis - previousMillis &gt; velocidade) {\r\n\/\/ save the last time you blinked the LED\r\npreviousMillis = currentMillis;\r\n\r\n\/\/ if the LED is off turn it on and vice-versa:\r\nif (ledState == LOW)\r\nledState = HIGH;\r\nelse\r\nledState = LOW;\r\n\r\n\/\/ set the LED with the ledState of the variable:\r\ndigitalWrite(led1Pin, ledState);\r\ndigitalWrite(led2Pin, !ledState);\r\n}\r\n}\r\n\r\nvoid playArp(int notes[]) {\r\n\/\/ iterate over the notes of the melody:\r\nfor (int thisNote = 0; thisNote &lt;= 3; thisNote++) { tone(8, notes[thisNote],100); \/\/ to distinguish the notes, set a minimum time between them. \/\/ the note's duration + 30% seems to work well: int pauseBetweenNotes = 100; delay(pauseBetweenNotes); \/\/ stop the tone playing: noTone(8); } for(int thisNote = 4; thisNote &gt;= 1; thisNote--) {\r\n\r\ntone(8, notes[thisNote],100);\r\n\r\n\/\/ to distinguish the notes, set a minimum time between them.\r\n\/\/ the note's duration + 30% seems to work well:\r\nint pauseBetweenNotes = 100;\r\ndelay(pauseBetweenNotes);\r\n\r\n}\r\n}\r\n<\/pre>\n<p><\/p>","protected":false},"excerpt":{"rendered":"<p class=\"post-excerpt\">Sounder bike is perfect to the safety of the cyclist, because when you ride on the street a lot of&#8230;<\/p>\n","protected":false},"author":1,"featured_media":394,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spay_email":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false},"categories":[4,46],"tags":[],"jetpack_featured_media_url":"https:\/\/i1.wp.com\/www.ateliehacker.com\/wp-content\/uploads\/2014\/02\/Sirene-de-Bike_cc.png?fit=1803%2C1416","jetpack_publicize_connections":[],"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p6TLCc-C","jetpack-related-posts":[{"id":27,"url":"http:\/\/www.ateliehacker.com\/en\/bike-pov\/","url_meta":{"origin":38,"position":0},"title":"Bike Mandala","date":"Tuesday February 25th, 2014","format":false,"excerpt":"Bike riding is good, but with LEDs is even better. Bike POV is a luminous device that drawings on bicycle wheel as it rotates. It is made with an Arduino, 11 LEDs that can be of any color and a control button to switch the drawn patterns. Materias: 1 Arduino\u2026","rel":"","context":"In &quot;Arduino&quot;","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/www.ateliehacker.com\/wp-content\/uploads\/2014\/02\/MG_04272.jpg?fit=1200%2C800&resize=350%2C200","width":350,"height":200},"classes":[]},{"id":896,"url":"http:\/\/www.ateliehacker.com\/en\/geek-princess\/","url_meta":{"origin":38,"position":1},"title":"Geek Princess","date":"Saturday July  4th, 2015","format":false,"excerpt":"Geek Princess's Tiara with LED RGB tape made with a button to choose the color. You want to learn to do? Come on... You will need: - LED Strip (RGB or white you choose) - Plain Tiara without props - Flex - Button with three terminals - Cola artisan (vinyl\u2026","rel":"","context":"In &quot;Make&quot;","img":{"alt_text":"","src":"https:\/\/i1.wp.com\/www.ateliehacker.com\/wp-content\/uploads\/2015\/07\/wpid-instasize_0704022148.jpg?fit=720%2C720&resize=350%2C200","width":350,"height":200},"classes":[]},{"id":326,"url":"http:\/\/www.ateliehacker.com\/en\/tenis-led-pisca\/","url_meta":{"origin":38,"position":2},"title":"[:en]Led Sneaker[:br]T\u00eanis que Pisca[:]","date":"Thursday January 22nd, 2015","format":false,"excerpt":"Imagine walking, dancing or running with a tennis flashing. That was the dream of many children who today have become adults. The bright shoes or tennis flashing, continues to attract widespread attention until now. The difference is that now anyone who wants to can make your shoes flashing LED tape.\u2026","rel":"","context":"In &quot;Make&quot;","img":{"alt_text":"","src":"https:\/\/i1.wp.com\/www.ateliehacker.com\/wp-content\/uploads\/2014\/04\/DSC01260.jpg?fit=750%2C1000&resize=350%2C200","width":350,"height":200},"classes":[]},{"id":75,"url":"http:\/\/www.ateliehacker.com\/en\/bike-led-de-seguranca\/","url_meta":{"origin":38,"position":3},"title":"[:en]Eco Lantern[:br]Eco Lanterna[:]","date":"Sunday February 23rd, 2014","format":false,"excerpt":"Ateli\u00ea Hacker at the Bike Lab - SESC Campinas - SP < \/ a> A flashlight bike is always good, especially to ride the night. Despite being an essential protective equipment for the cyclist, is not all biciclata which has one, because sometimes they are not accessible. And so if\u2026","rel":"","context":"In &quot;Eletr\u00f4nica&quot;","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/www.ateliehacker.com\/wp-content\/uploads\/2014\/03\/lanterna-rainbow11.jpg?fit=1024%2C768&resize=350%2C200","width":350,"height":200},"classes":[]},{"id":1233,"url":"http:\/\/www.ateliehacker.com\/en\/light-swing\/","url_meta":{"origin":38,"position":4},"title":"[:en]Light Poi[:br]Malabares de Luz[:]","date":"Sunday July  5th, 2015","format":false,"excerpt":"The Light Swing device is made with high-brightness LEDs, controlled by a microcontroller programmed with Arduino. Currently, consists of a series of 11 individually controlled LEDs to draw visual patterns in the air.","rel":"","context":"In &quot;Arduino&quot;","img":{"alt_text":"","src":"https:\/\/i1.wp.com\/www.ateliehacker.com\/wp-content\/uploads\/2015\/07\/541899_253261414804451_2135883280_n.jpg?fit=960%2C641&resize=350%2C200","width":350,"height":200},"classes":[]},{"id":620,"url":"http:\/\/www.ateliehacker.com\/en\/performance-cyberwear\/","url_meta":{"origin":38,"position":5},"title":"Performance Cyberwear","date":"Friday February 13th, 2015","format":false,"excerpt":"Cyber Wear is a performance with electronic costume designed by Atelier Hacker. It uses an Arduino circuit that controls two servo motors, providing wing movements controlled by the performer, driven by fixed button on the costume. The light of the costumes are made with wire eletroluminecente called EL wire. Poliana\u2026","rel":"","context":"In &quot;Performance&quot;","img":{"alt_text":"","src":"https:\/\/i1.wp.com\/www.ateliehacker.com\/wp-content\/uploads\/2015\/02\/91.jpg?fit=1200%2C900&resize=350%2C200","width":350,"height":200},"classes":[]}],"_links":{"self":[{"href":"http:\/\/www.ateliehacker.com\/en\/wp-json\/wp\/v2\/posts\/38"}],"collection":[{"href":"http:\/\/www.ateliehacker.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.ateliehacker.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.ateliehacker.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.ateliehacker.com\/en\/wp-json\/wp\/v2\/comments?post=38"}],"version-history":[{"count":4,"href":"http:\/\/www.ateliehacker.com\/en\/wp-json\/wp\/v2\/posts\/38\/revisions"}],"predecessor-version":[{"id":393,"href":"http:\/\/www.ateliehacker.com\/en\/wp-json\/wp\/v2\/posts\/38\/revisions\/393"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/www.ateliehacker.com\/en\/wp-json\/wp\/v2\/media\/394"}],"wp:attachment":[{"href":"http:\/\/www.ateliehacker.com\/en\/wp-json\/wp\/v2\/media?parent=38"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.ateliehacker.com\/en\/wp-json\/wp\/v2\/categories?post=38"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.ateliehacker.com\/en\/wp-json\/wp\/v2\/tags?post=38"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}