Alcoholemia 2 Arduino (6 / 10 paso)

Paso 6: código de

 #include <Adafruit_Thermal.h> 
 #define qtyLED 6 //Declare the quantity of LED's for the bar graph 
 <adafruit_thermal.h><br>#include <SoftwareSerial.h><softwareserial.h> SoftwareSerial mySerial(0, 1); Adafruit_Thermal printer(&mySerial); int printer_RX_Pin = 0; int printer_TX_Pin = 1; int LEDs[qtyLED]; //Array to store the states of the LEDs int sensorPin = 0; //Variable that will hold the current value of the sensor int time; //Variable that will hold the amount of time for the sensor to be read int maxreading; //Variable to store the maximum value read during the last reading //For loop counting variables int i; int j; void setup() { mySerial.begin(19200); printer.begin();</softwareserial.h></adafruit_thermal.h> 
 //Initialize the counting variables i=0; j=2; while(i < qtyLED) //While i is less than the number of defined LED's { //...save the value of i+2 in the LEDs array. we add 2 so that it represents one of our digital pins LEDs[i] = j; i++; j++; } for(i=0;i<qtyled;i++) define="" the="" led="" pins="" as="" outputs.="" in="" this="" case="" 2-="">7 { pinMode(LEDs[i], OUTPUT); } pinMode(13, OUTPUT); //Define pin 13 as an output so we can show when we are not taking a reading from the sensor(Blinkin //...Or when we are taking a reading from the sensor (Solid) }</qtyled;i++)> 
 void loop() { PORTB = PORTB ^ 100000; //Invert pin 13 to give the LED a blinking effect delay(100); //Delay so that the user can see the blinking happen int sensor = analogRead(sensorPin); //Read the sensors value and store it in the sensor variable if(sensor >= 40) //If the value is less that 40(value for the chemical being used in this example) { printer.println("Breathalyzer 2.Arduino"); //printer will start and print the first statement (if the value is less than 40) printer.print("Hey! Look at you! "); printer.print("You are sober!! That's a shocker!"); printer.feed(); printer.println("Now quick, before your friends call you back over for that next shot you should just go home"); printer.println("Doesn't Netflix and a bed sound fun?"); printer.println("If that doesn't tickle your fancy and you plan on drinking tonight please call"); printer.feed(); printer.println("*850.433.3333*"); printer.feed(); printer.feed(); printer.feed(); printer.println("For entertainment purposes only"); printer.feed(); } { digitalWrite(13, HIGH); //Turn on the blue LED indecating that the sensor detected a minimal amount of alcohol (sensor >= 40) maxreading = 0; //Initiate the max reading to 0 for(time = 0;time <= 5000;time++) //Read the sensor for 5 seconds { //...every millisecond update the value of the max reading of the sensor int sensor = analogRead(sensorPin); delay(1); if(sensor > maxreading) { maxreading = sensor; } digitalWrite(13, LOW); //As soon as the reading is complete turn off the blue LED int level = map(maxreading, 0, 200, 0, qtyLED); //Map the value from 0 to 200(reading from sensor) to 0 and the number of LEDs which is 6 //...0 to 6(LEDs) level determines how many of them turn on. for(i=0;i<qtyled;i++) compare="" all="" the="" leds="" current="" state="" with="" value="" of="" level="" that="" was="" read="" ="" {="" if="" for="" example="" 5,="" then="" 2-="">6 would turn on. if (i < level) //If the current LED being checked is less that the level { printer.println("Breathalyzer 2.Arduino");//printer will start and print the first statement (if the value is between 40 and the max) printer.print("Well well well...."); printer.print("It looks like you've had a bit to drink. You should probably stop now. That's what all the cool kids are doing"); printer.feed(); printer.println("Besides, do you really want to be THAT GUY?"); printer.println("Now, go pay your bar tab and please call"); printer.feed(); printer.println("*850.433.3333*"); printer.feed(); printer.feed(); printer.feed(); printer.println("For entertainment purposes only"); printer.feed();{ digitalWrite(LEDs[i], HIGH); //...Turn it on } } else //If the current LED being checked is higher than the level { digitalWrite(LEDs[i], LOW); //...Turn it off } { printer.println("Breathalyzer 2.Arduino");//printer will start and print the first statement (if the value is at the maximum level) printer.print("HOT DOGGY"); printer.print("You are as drunk as a SKUNK!!"); printer.println("I could tell you pretty much anything right now and you wouldn't remember it"); printer.feed(); printer.println("fajksdfjalksfjalkdfja;l "); printer.println("Just Kidding! But Seriously, you should probably put that beer down and call"); printer.feed(); printer.println("*850.433.3333*"); printer.println("It's bedtime."); printer.feed(); printer.feed(); printer.feed(); printer.println("For entertainment purposes only"); printer.feed(); } } delay(10000); //Wait 10 seconds for the user to get the reading from the led bar graph for(i=0;i<qtyled;i++) turn="" off="" all="" the="" leds="" ="" {="" digitalwrite(leds[i],low);="" }="" }<="" p=""></qtyled;i++)></qtyled;i++)>],LOW); 
 } } } } 

Artículos Relacionados

Alcoholemia de Arduino

Alcoholemia de Arduino

¿Qué es un alcoholímetro que se puede pedir? Es un dispositivo para estimar el contenido del alcohol de la sangre (BAC) de una muestra de aliento. En términos simples es un dispositivo para probar el tiempo en una persona es borracho o no. Como el tí
Remix de alcoholemia 2.0 (Alcohol metro)

Remix de alcoholemia 2.0 (Alcohol metro)

Mensaje: Por favor hacer tu ciudad limpia y decir NO a las bolsas de plástico, utiliza bolsas de papel reciclado. PLANTAR MÁS ÁRBOLES Y HACER DE ESTA TIERRA VERDE. Utilizar viejas piezas de reciclaje para proyectos y ahorrar dinero y medio ambiente.
El ecualizador de gráfico de alcoholemia de simulador de relámpago - Arduino Powered

El ecualizador de gráfico de alcoholemia de simulador de relámpago - Arduino Powered

ACTUALIZACIÓN: Una versión portable de la alcoholemia que habla aquí es http://talkingbreathalyzer.com ***Las tiras LED están montadas en un trellace al aire libre que funciona como un simulador de rayos, alcoholemia al aire libre, ecualizador gráfic
Alcoholemia de yoga

Alcoholemia de yoga

yoga alcoholemia es una herramienta de visualización de respiración para ayudarle a entender y ponerse en contacto con tu respiración. La respiración es la base del yoga y la meditación, y esta herramienta de biofeedback es una forma de desarrollar u
DIY Magic Mirror y Photobooth - Arduino Powered

DIY Magic Mirror y Photobooth - Arduino Powered

un kit montado para este proyecto ya está disponible enSeeedstudio.comMás información en este proyecto en http://diymagicmirror.com El software para este proyecto es de código abiertoQue es la más bella de todas ellas. Haga su propio Magic Mirror y d
Micrófono de alcoholemia

Micrófono de alcoholemia

el micrófono de alcoholemia es un sistema para la colección de inconscpicuous de conjuntos de datos de nivel contenido de alcohol en la sangre. En otras palabras, puede medir la sobriedad de una persona con un dispositivo, que se ve por todos los efe
Alcoholemia portátil DIY - enviado por BayLab para el programa de patrocinio de Instructables

Alcoholemia portátil DIY - enviado por BayLab para el programa de patrocinio de Instructables

detectar su BAC wih un bolsillo tamaño alcoholemia.Paso 1: descargo de responsabilidadAntes que comencemos, un descargo de responsabilidad. Esto no pretende ser utilizado para decir si es aceptable para conducir o no. No es tan preciso como un policí
Monitor de Arduino BAC

Monitor de Arduino BAC

El propósito de este proyecto es utilizar un arduino y un sensor de alcohol MQ-3 para hacer una simple alcoholemia que monitorea niveles de BAC. El proyecto consiste en diseñar y construir un circuito simple y escribir código en arduino. Este monitor
La alcoholemia hablando

La alcoholemia hablando

*** información adicional en http://droidalyzer.com/talkingbreathalyzer/ ***Video de la alcoholemia hablando en acción:Más detalles sobre la alcoholemia hablando:Un alcoholímetro personalizable que habla y te dice cuánto has tenido que beber. También
Metro Ultravioleta y alcoholemia Llavero - 3D impreso - IoT Blynk

Metro Ultravioleta y alcoholemia Llavero - 3D impreso - IoT Blynk

Imaginar el viaje de playa ideal. El sol brilla, el cielo está azul, el agua está caliente. Tú y tus amigos tienen todo que lo necesario para tomar el sol, arena y surf. Bueno, no te olvides el gel de aloe para aliviar el dolor en su refrigerador, pa
Ventilador con control de temperatura Arduino

Ventilador con control de temperatura Arduino

Yo y unos pocos miembros del grupo hemos decidido que, para el verano, sería beneficioso crear un ventilador que se enciende a 70 grados Fahrenheit y continúa aumentando en intensidad con el calor. Por lo es lo que hicimos. :)Paso 1: engranajes En pr
Arduino y Neopixel coque botella fiesta luz

Arduino y Neopixel coque botella fiesta luz

Así que mi hijo Doon puntos una luz genial partido hecho de botellas de Coca-Cola y las tripas pegajosas de palillos del resplandor y pregunta si podemos hacer uno para su próxima PartAYYY Escuela exámenes son sobre escape !!!!!! Digo seguro, pero no
Arduplane - rc aviones basados en Arduino

Arduplane - rc aviones basados en Arduino

Avión RC es uno de los juguetes más grandes de con que todo el mundo quiere jugar. Pero comprar uno puede ser más costoso permite ensuciarse las manos y construir uno para nosotros mismos utilizando los reguladores micro Arduino. Permite hacer nuestr
BRICOLAJE - cómo utilizar la Arduino Uno para enviar un correo electrónico, SMS y hacer una voz llamar

BRICOLAJE - cómo utilizar la Arduino Uno para enviar un correo electrónico, SMS y hacer una voz llamar

¿Se pregunta cómo enviar correos electrónicos a través de tu Arduino Uno? No te preocupes... Este vídeo tutorial ilumine sobre el proceso paso a paso para enviar correos electrónicos, mensajes SMS, así como hacer voz llamar usando el 3G/GPRS shield l