{"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\/br\/bike-sirene\/","title":{"rendered":"Sirene de Bike"},"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\/br\/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>Sirene para bicicleta \u00e9 otimo para a seguran\u00e7a do ciclista, pois quando se pedala na rua muita vezes se tem a necessida de avisar: &#8220;Olha eu estou aqui!&#8221;. Seja para um carro, \u00f4nibus ou mesmo pedestre, temos que ficar alerta e nos fazer vis\u00edveis. Com esse projeto voc\u00ea pode construir uma sirene para sua bike com um Arduino. Esse prot\u00f3tipo conta com uma buzzer de 12V com 3 toques diferente e leds que piscam na frequ\u00eancia do audio.<\/p>\n<h2>Materiais<\/h2>\n<p>1 Arduino<br \/>\n2 LEDs<br \/>\n3 Pushbutton<br \/>\n3 Resistores 10K Ohm<br \/>\n1 Resistores 2.2K Ohm<br \/>\n2 Resistores 220 Ohm<br \/>\n1 Transistor NPN 2222A<br \/>\n1 Bateria 9V<br \/>\n1 Soquete de bateria 9V<\/p>\n<p><iframe loading=\"lazy\" src=\"\/\/www.youtube.com\/embed\/ozG9ZyN8iI4\" width=\"640\" height=\"360\" frameborder=\"0\" allowfullscreen=\"allowfullscreen\"><\/iframe><\/p>\n<p>Neste video o circuito usava um buzzer de 3V. Posteriormente foi implementado um buzzer 12V utilizando um transistor NPN 2222A, conforme pode ser visto no diagrama abaixo. Assim o som fica mais alto, tornando mais seguro em certas situa\u00e7\u00f5es onde o volume \u00e9 mais cr\u00edtico.<\/p>\n<h2>Circuito<\/h2>\n<p><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\/br\/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>C\u00f3digo Arduino<\/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\">Sirene para bicicleta \u00e9 otimo para a seguran\u00e7a do ciclista, pois quando se pedala na rua muita vezes se tem&#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\/br\/bike-pov\/","url_meta":{"origin":38,"position":0},"title":"Bike Mandala","date":"25 de fevereiro de 2014","format":false,"excerpt":"Andar de bike \u00e9 bom,\u00a0 mas com LEDs \u00e9 melhor ainda. Bike POV \u00e9 um dispositivo luminoso que faz desenhos na roda da bicicleta conforme ela gira.\u00a0 Ele \u00e9 feito com um Arduino, 11 leds que podem ser de qualquer cor e um bot\u00e3o de controle para trocar os padr\u00f5es\u2026","rel":"","context":"Em &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\/br\/geek-princess\/","url_meta":{"origin":38,"position":1},"title":"Geek Princess","date":"04 de julho de 2015","format":false,"excerpt":"Geek Princess \u00e9 a Tiara com fita de LED RGB feita com um bot\u00e3o para escolher a cor. Quer aprender a fazer ?\u00a0 Vamos l\u00e1... Voc\u00ea vai precisar de: - Fita de LED (RGB ou branca voc\u00ea escolhe) - Tiara lisa sem adere\u00e7os - Cabo flex\u00edvel - Bot\u00e3o com tr\u00eas\u2026","rel":"","context":"Em &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\/br\/tenis-led-pisca\/","url_meta":{"origin":38,"position":2},"title":"[:en]Led Sneaker[:br]T\u00eanis que Pisca[:]","date":"22 de janeiro de 2015","format":false,"excerpt":"Imagine andar, dan\u00e7ar ou correr com um t\u00eanis que pisca. Esse foi o sonhos de muitas crian\u00e7as, que hoje j\u00e1 se tornaram adultos. O cal\u00e7ado luminoso ou tenis que pisca, continua atraindo a aten\u00e7\u00e3o geral at\u00e9 hoje. A diferen\u00e7a \u00e9 que agora quem quiser pode fazer o seu t\u00eanis que\u2026","rel":"","context":"Em &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\/br\/bike-led-de-seguranca\/","url_meta":{"origin":38,"position":3},"title":"[:en]Eco Lantern[:br]Eco Lanterna[:]","date":"23 de fevereiro de 2014","format":false,"excerpt":"Ateli\u00ea Hacker no Bike Lab - Sesc Campinas - SP Uma lanterna para bicicleta \u00e9 sempre bom, especialmente para pedalar a noite. Apesar de ser um equipamento de prote\u00e7\u00e3o essencial para o ciclista, n\u00e3o \u00e9 toda biciclata que conta com uma, pois as vezes elas n\u00e3o s\u00e3o acess\u00edveis. E para\u2026","rel":"","context":"Em &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\/br\/light-swing\/","url_meta":{"origin":38,"position":4},"title":"[:en]Light Poi[:br]Malabares de Luz[:]","date":"05 de julho de 2015","format":false,"excerpt":"O Malabares de Luz \u00e9 feito com leds de alto brilho e controlados por um microcontrolador programado com Arduino. Atualmente \u00e9 composto por uma serie de 11 leds controlados individualmente para desenhar padr\u00f5es visuais no ar.","rel":"","context":"Em &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\/br\/performance-cyberwear\/","url_meta":{"origin":38,"position":5},"title":"Performance Cyberwear","date":"13 de fevereiro de 2015","format":false,"excerpt":"Cyberwear \u00e9 uma performance com figurino eletr\u00f4nicos desenvolvido pelo Ateli\u00ea Hacker. Utiliza um circuito com Arduino que controla dois motores servos, proporcionando movimentos de asa controlados pela performer, acionado por bot\u00e3o fixado no figurino. A parte luminosa do figurino \u00e9 feito com fio eletroluminecente denominado EL wire. Poliana Nataraja \u00e9\u2026","rel":"","context":"Em &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\/br\/wp-json\/wp\/v2\/posts\/38"}],"collection":[{"href":"http:\/\/www.ateliehacker.com\/br\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.ateliehacker.com\/br\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.ateliehacker.com\/br\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.ateliehacker.com\/br\/wp-json\/wp\/v2\/comments?post=38"}],"version-history":[{"count":4,"href":"http:\/\/www.ateliehacker.com\/br\/wp-json\/wp\/v2\/posts\/38\/revisions"}],"predecessor-version":[{"id":393,"href":"http:\/\/www.ateliehacker.com\/br\/wp-json\/wp\/v2\/posts\/38\/revisions\/393"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/www.ateliehacker.com\/br\/wp-json\/wp\/v2\/media\/394"}],"wp:attachment":[{"href":"http:\/\/www.ateliehacker.com\/br\/wp-json\/wp\/v2\/media?parent=38"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.ateliehacker.com\/br\/wp-json\/wp\/v2\/categories?post=38"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.ateliehacker.com\/br\/wp-json\/wp\/v2\/tags?post=38"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}