Safety Car
Autor: Fellipe Couto | Publicado: 2012-10-31T21:04:00-02:00

Fala ae! Fala ae!
Sabe quando você precisa de mais que um pisca-alerta no trânsito? 




Eu imagino que circular com isso ligado não seja permitido por lei, mas uma vez ou outra, usando com responsabilidade... Só não falar pra polícia que aprenderam aqui no blog, ta bom!

Usei um par dessas lanternas de Leds que encontramos em qualquer loja de peças pra automóveis, e até em camelô já vi vendendo. Esse modelo são 8 Leds em cada.

O circuito fiz baseado na plataforma Arduino e foi montado numa placa de fenolite de 7x4cm.

Como podem ver no código do microcontrolador, existe uma chave que liga sinal alto ao pino 9. Dessa forma podemos deixar a lanterna sempre ligada, sem o pisca.

Agora é só instalar no carro!

Segue o esquema elétrico do circuito, fotos da pci, e o código fonte












/*----------------- 
&nbsp;S A F E T Y&nbsp; C A R
&nbsp;Fellipe Couto
&nbsp;16/09/2012
&nbsp;-----------------*/
#define L1 2
#define L2 3
#define strobe 9

void setup(){
&nbsp; pinMode(L1,OUTPUT);
&nbsp; pinMode(L2,OUTPUT); 
&nbsp; pinMode(strobe, INPUT);
}

void loop(){
&nbsp; if (digitalRead(strobe) == HIGH){
&nbsp;&nbsp;&nbsp; strobe1(15);
&nbsp;&nbsp;&nbsp; strobe2(12);
&nbsp;&nbsp;&nbsp; strobe3(7);
&nbsp;&nbsp;&nbsp; strobe4(7);
&nbsp; }
&nbsp; else{
&nbsp;&nbsp;&nbsp; digitalWrite(L1, HIGH);
&nbsp;&nbsp;&nbsp; digitalWrite(L2, HIGH); 
&nbsp; }
}

void strobe1(int qtd){
&nbsp; int t = 50;
&nbsp; for (int q=0; q&lt;qtd; q++){
&nbsp;&nbsp;&nbsp; for (int i=0; i&lt;3; i++){
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; digitalWrite(L1,HIGH);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; delay(t);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; digitalWrite(L1,LOW);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; delay(t);
&nbsp;&nbsp;&nbsp; }
&nbsp;&nbsp;&nbsp; for (int i=0; i&lt;3; i++){
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; digitalWrite(L2,HIGH);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; delay(t);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; digitalWrite(L2,LOW);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; delay(t);
&nbsp;&nbsp;&nbsp; }
&nbsp; }
}

void strobe2(int qtd){
&nbsp; int x = 5;
&nbsp; int t = 40;
&nbsp; for (int q=0; q&lt;qtd; q++){
&nbsp;&nbsp;&nbsp; for (int i=0; i&lt;x; i++){
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; digitalWrite(L1,HIGH);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; digitalWrite(L2,HIGH);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; delay(t);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; digitalWrite(L1,LOW);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; digitalWrite(L2,LOW);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; delay(t);
&nbsp;&nbsp;&nbsp; }
&nbsp;&nbsp;&nbsp; delay(200);
&nbsp; }
}

void strobe3(int qtd){
&nbsp; int t = 400;
&nbsp; int t1 = 60;
&nbsp; for (int i=0; i&lt;qtd; i++){
&nbsp;&nbsp;&nbsp; digitalWrite(L1,HIGH);
&nbsp;&nbsp;&nbsp; digitalWrite(L2,HIGH);
&nbsp;&nbsp;&nbsp; delay(20);
&nbsp;&nbsp;&nbsp; digitalWrite(L1,LOW);
&nbsp;&nbsp;&nbsp; digitalWrite(L2,LOW);
&nbsp;&nbsp;&nbsp; delay(t);
&nbsp;&nbsp;&nbsp; digitalWrite(L1,HIGH);
&nbsp;&nbsp;&nbsp; delay(t1);
&nbsp;&nbsp;&nbsp; digitalWrite(L1,LOW);
&nbsp;&nbsp;&nbsp; digitalWrite(L2,HIGH);
&nbsp;&nbsp;&nbsp; delay(t1);
&nbsp;&nbsp;&nbsp; digitalWrite(L2,LOW);
&nbsp;&nbsp;&nbsp; digitalWrite(L1,HIGH);
&nbsp;&nbsp;&nbsp; delay(t1);
&nbsp;&nbsp;&nbsp; digitalWrite(L1,LOW);
&nbsp;&nbsp;&nbsp; digitalWrite(L2,HIGH);
&nbsp;&nbsp;&nbsp; delay(t1);
&nbsp;&nbsp;&nbsp; digitalWrite(L1,LOW);
&nbsp;&nbsp;&nbsp; digitalWrite(L2,LOW);
&nbsp;&nbsp;&nbsp; delay(t);
&nbsp; }
}

void strobe4(int qtd){
&nbsp; int t = 20;
&nbsp; int t1 = 500;
&nbsp; for (int i=0; i&lt;qtd; i++){
&nbsp;&nbsp;&nbsp; digitalWrite(L1,HIGH);
&nbsp;&nbsp;&nbsp; digitalWrite(L2,HIGH);
&nbsp;&nbsp;&nbsp; delay(t);
&nbsp;&nbsp;&nbsp; digitalWrite(L1,LOW);
&nbsp;&nbsp;&nbsp; digitalWrite(L2,LOW);
&nbsp;&nbsp;&nbsp; delay(t1);
&nbsp; }
}