Francesco ManettiSimona Pira
Published © GPL3+

An alcohol tester with LED lights made with Zerynth

How to build a device for estimating blood alcohol content from a breath sample. Developed with Zerynth and an ARM board.

BeginnerWork in progress9,617
An alcohol tester with LED lights made with Zerynth

Things used in this project

Hardware components

Arduino Due
Arduino Due
×1
MQ-3 Alcool Gas Sensor
×1
Resistor 4.7K ohm
×1
Resistor 10K ohm
×1
LED (generic)
LED (generic)
×9
Resistor 220 ohm
Resistor 220 ohm
×9

Software apps and online services

Zerynth Studio
Zerynth Studio

Story

Read more

Schematics

Alcohol Test Circuit

Code

An alcohol tester with LED lights made with Zerynth

Python
Paste this code into Zerynth Studio.
import streams
import adc

q=streams.serial()

digitalout=[D4,D5,D6,D7,D8,D9,D10,D11,D12]
calibration=[2000,1800,1600,1400,1200,1100,900,750,500]
min=750

for pin in digitalout:
    pinMode(pin,OUTPUT)

while True:
        alcool=adc.read(A0)
        
        if(alcool<=calibration[8]):
            on=[D12]
            for d in digitalout:
                if d in on:
                    digitalWrite(d,HIGH)
                else:
                    digitalWrite(d,LOW)
        if(alcool<=calibration[7] and alcool>calibration[8]):
            on=[D11,D12]
            for d in digitalout:
                if d in on:
                    digitalWrite(d,HIGH)
                else:
                    digitalWrite(d,LOW)
        if(alcool<=calibration[6] and alcool>calibration[7]):
            on=[D10,D11,D12]
            for d in digitalout:
                if d in on:
                    digitalWrite(d,HIGH)
                else:
                    digitalWrite(d,LOW)
        if(alcool<=calibration[5] and alcool>calibration[6]):
            on=[D9,D10,D11,D12]
            for d in digitalout:
                if d in on:
                    digitalWrite(d,HIGH)
                else:
                    digitalWrite(d,LOW)
        if(alcool<=calibration[4] and alcool>calibration[5]):
            on=[D8,D9,D10,D11,D12]
            for d in digitalout:
                if d in on:
                    digitalWrite(d,HIGH)
                else:
                    digitalWrite(d,LOW)
        if(alcool<=calibration[3] and alcool>calibration[4]):
            on=[D7,D8,D9,D10,D11,D12]
            for d in digitalout:
                if d in on:
                    digitalWrite(d,HIGH)
                else:
                    digitalWrite(d,LOW)
        if(alcool<=calibration[2] and alcool>calibration[3]):
            on=[D6,D7,D8,D9,D10,D11,D12]
            for d in digitalout:
                if d in on:
                    digitalWrite(d,HIGH)
                else:
                    digitalWrite(d,LOW)
        if(alcool<=calibration[1] and alcool>calibration[2]):
            on=[D5,D6,D7,D8,D9,D10,D11,D12]
            for d in digitalout:
                if d in on:
                    digitalWrite(d,HIGH)
                else:
                    digitalWrite(d,LOW)
        if(alcool>calibration[0]):
            on=[D4,D5,D6,D7,D8,D9,D10,D11,D12]
            for d in digitalout:
                if d in on:
                    digitalWrite(d,HIGH)
                else:
                    digitalWrite(d,LOW)
        sleep(500)
        print(alcool)

Credits

Francesco Manetti

Francesco Manetti

2 projects • 10 followers
Simona Pira

Simona Pira

1 project • 5 followers

Comments