Smell Voter

Hi,

I want to create a project which will allow me to check smells good or bad.

There will be 3 pushbuttons,
1 green led
1 red led
1 rgb led
1 airwich board for activating deodorant spray

when i press first button , which will be connected to airwick deodorant board and makes it spray after 1 sec delay, in same time 1st button has to activate 2nd and 3rd button for press and their led lights.

There will be 2 leds inside 2nd and 3rd buttons. after activating theese 2 buttons by 1st button, 2nd button's green led will light up for 15 seconds and in same time 3rd buttons red light will light up for 15 seconds also for to make user to see buttons activated for voteing. This will allow users to choose bad or good smell by pressing red or green button.

if red button choosed, rgb red light will fade in red,
if green button choosed, rgb light will fade in green,

after 5 seconds rgb led has to get low,

after another 5 seconds rgb led light get high with the color which is avarage vote color.

Also user has to be limited for 15 second to not use 1st button again after first press.

Can someone help me for coding this with arduino uno R3 and for wiring shematic?

Kind Regards

How about a link to the smell sensor?

There will be no smell sensor except your nose. İf you think smell is bad you will press red button, if you thinl smell is good you will press green one.

If you go through the examples that come with the Arduino you will see how to read buttons and how to dim LED’s - PWM, analogWrite().
Going through the examples teaches you a lot about how the Arduino language works.

Thansk for advice, but i dont have much time for creating this project. For Pros it can be easy to help me , thats why i asked for it, maybe someone can help for starting to code and algorithm...

If you don't have time to make this, maybe you shouldn't make it.
I can copy and paste the example code for you but in the end you still have to make it.

a starter, not complete but you should get started.

const int redButton = 3;
const int redLed = 4;
int redstate = LOW;

const int greenButton= 5;
const int greenLed = 6;
int greenstate = LOW;

void setup() 
{
  Serial.begin(115200);
  Serial.println("Start ");

  pinMode(redButton, INPUT);
  pinMode(redLED, OUTPUT);'

  pinMode(greenButton, INPUT);
  pinMode(greenLed , OUTPUT);'

  digitalWrite(redLed, redstate);
  digitalWrite(greenLed , greenstate );
}

void loop() 
{
  if (digitalRead(redButton) == HIGH && redstate == LOW)
  {
    redstate = HIGH;
    greenstate = LOW;
  }

  if (digitalRead(greenButton) == HIGH && greenstate == LOW)
  {
    greenstate = HIGH;
    redstate = LOW;
  }
  
  digitalWrite(redLed, redstate);
  digitalWrite(greenLed, greenstate);

}

Your turn to expand this code with yellow

but i dont have much time for creating this project.

Moderator: should I move this request to the gigs and collaboration section?

Thanks it will help me to get start ,actually i already started but new phrases i get from that, i will reply it soon with final code.
kind regards.

bturcan:
Thansk for advice, but i dont have much time for creating this project. For Pros it can be easy to help me , thats why i asked for it, maybe someone can help for starting to code and algorithm…

If you want someone to write the program for a fee ask in the Gigs and Collaborations section of the Forum

…R

Thanks, i think i will finish soon and it will be usefull for many retail people. I will share last time for pros to check the code for correction.

Here is the code. All system is working but i only need one help from pros, i also use ethernet shield over uno r3 and i want to add sdcard abilities to this code.

I have to count press amounts to each button and then write it to sdcard with 3 different file, like spray.txt,red.txt and green.txt

When system starts ws2801 has to show the avarage vote color ,also it has to show avarage color after 10 seconds of each voting.Somehow i have to record press amounts then make percent calculation with them and add if statement like “if green buton percent higher than red button light up ws2801 with green color” If someone can help i will be glad for that.

//SMELL VOTER- by Burak TURCAN

#include<FTRGBLED.h>
#include<SPI.h>
#define Pbuton 5 // spray button
#define Kbuton 6 // red vote button
#define Ybuton 7 // green vote button
#define YKLed 8 // red and green button led (will be in blink mode until vote button pressed. After 15 sec. go LOW
#define PIN_CKI 2 // WS2801 connection pins
#define PIN_SDI 3 // WS2801 connection pins
#define PLed A0 // spray button yelow led
#define roLeP 11// spray button relay 
#define roLeK 12// red button relay
#define roLeY 13//green button relay
#define kokuM 9//spray triger which connecting to smell emitter device
int pbtn=0;
int kbtn=0;
int ybtn=0;
const int NUM_LEDS = 10;
RGBLEDChain leds(NUM_LEDS,PIN_CKI,PIN_SDI);
int x=0;
int y=0;
int z=0;
int a=0;
int b=0;
int c=0;
 void setup()
 {
 Serial.begin(9600);
 leds.begin();
 pinMode(Pbuton, INPUT);//spray relay
 pinMode(Kbuton, INPUT);//red button relay
 pinMode(Ybuton, INPUT);//green button relay
 pinMode(YKLed, OUTPUT);//green and red blinking leds
 pinMode(PLed, OUTPUT);//spray button yellow led
 pinMode(kokuM, OUTPUT);//sray triger
 pinMode(roLeP, OUTPUT);//spray button
 pinMode(roLeK, OUTPUT);//red button
 pinMode(roLeY, OUTPUT);//green button
 }
  void loop()
  {
   kbtn =digitalRead(Kbuton);
   ybtn =digitalRead(Ybuton); 
   pbtn =digitalRead(Pbuton);
   digitalWrite(PLed, HIGH);
   digitalWrite(YKLed, LOW);
   digitalWrite(kokuM, LOW);
   digitalWrite(roLeP, LOW);//spray button relay is activated
   digitalWrite(roLeK, HIGH);//red button relay is passive
   digitalWrite(roLeY, HIGH);//green button relay passive
   leds.setLED(0, { 0, 0, 0 });//WS2801 LED0 off
   leds.setLED(1, { 0, 0, 0 });//WS2801 LED1 off
   leds.setLED(2, { 0, 0, 0 });//WS2801 LED2 off
   leds.setLED(3, { 0, 0, 0 });//WS2801 LED3 off
   leds.setLED(4, { 0, 0, 0 });//WS2801 LED4 off
   leds.setLED(5, { 0, 0, 0 });//WS2801 LED5 off
   leds.setLED(6, { 0, 0, 0 });//WS2801 LED6 off
   leds.setLED(7, { 0, 0, 0 });//WS2801 LED7 off
   leds.setLED(8, { 0, 0, 0 });//WS2801 LED8 off
   leds.setLED(9, { 0, 0, 0 });//WS2801 LED9 off
   leds.update();
   
   switch(pbtn)
   {
   case HIGH:
   digitalWrite(roLeP, HIGH);
   digitalWrite(PLed, LOW);
   digitalWrite(kokuM, HIGH);
   delay(1000);
   digitalWrite(kokuM, LOW);
   
   for(x=0;x<75;x++)
   {
   digitalWrite(YKLed, HIGH);
   oy();
   delay(100);
   digitalWrite(YKLed, LOW);
   oy();
   delay(100);
   digitalWrite(roLeK, LOW);
   digitalWrite(roLeY, LOW);
   
   }
   break;
   case LOW:
   digitalWrite(YKLed, LOW);
   digitalWrite(kokuM, LOW);
   digitalWrite(PLed, LOW);
   digitalWrite(roLeP, LOW);
   digitalWrite(roLeK, HIGH);
   digitalWrite(roLeY, HIGH);
   leds.setLED(0, { 0, 0, 0 });//WS2801 LED0 off
   leds.setLED(1, { 0, 0, 0 });//WS2801 LED1 off
   leds.setLED(2, { 0, 0, 0 });//WS2801 LED2 off
   leds.setLED(3, { 0, 0, 0 });//WS2801 LED3 off
   leds.setLED(4, { 0, 0, 0 });//WS2801 LED4 off
   leds.setLED(5, { 0, 0, 0 });//WS2801 LED5 off
   leds.setLED(6, { 0, 0, 0 });//WS2801 LED6 off
   leds.setLED(7, { 0, 0, 0 });//WS2801 LED7 off
   leds.setLED(8, { 0, 0, 0 });//WS2801 LED8 off
   leds.setLED(9, { 0, 0, 0 });//WS2801 LED9 off
   leds.update();
   break;
   }
  }
   void oy()
   {
    kbtn =digitalRead(Kbuton);
    ybtn =digitalRead(Ybuton);  
    if(kbtn==HIGH)
    {
    if(ybtn==HIGH)
    {
    for(int f=0;f<2;f++)
    {
    bosluk();
    }
    }
    }
    switch(kbtn)
    {
    case HIGH:
    x=75;
    digitalWrite(roLeY, HIGH);
    digitalWrite(roLeK, HIGH);
    digitalWrite(YKLed, LOW);
    digitalWrite(PLed, LOW);
    digitalWrite(kokuM, LOW);
    digitalWrite(roLeP, HIGH);
    for(y=0;y<255;y++)
    {
    leds.setLED(0, { 0, 0, y });
    leds.setLED(1, { 0, 0, y });
    leds.setLED(2, { 0, 0, y });
    leds.setLED(3, { 0, 0, y });
    leds.setLED(4, { 0, 0, y });
    leds.setLED(5, { 0, 0, y });
    leds.setLED(6, { 0, 0, y });
    leds.setLED(7, { 0, 0, y });
    leds.setLED(8, { 0, 0, y });
    leds.setLED(9, { 0, 0, y });
    leds.update();
    delay(20);
    }
    for(a=255;a>0;a--)
    {
    leds.setLED(0, { 0, 0, a });
    leds.setLED(1, { 0, 0, a });
    leds.setLED(2, { 0, 0, a });
    leds.setLED(3, { 0, 0, a });
    leds.setLED(4, { 0, 0, a });
    leds.setLED(5, { 0, 0, a });  
    leds.setLED(6, { 0, 0, a });
    leds.setLED(7, { 0, 0, a });
    leds.setLED(8, { 0, 0, a });
    leds.setLED(9, { 0, 0, a });
    leds.update();
    delay(20);
    }
    break;
    }
    switch(ybtn)
    {
    case HIGH:
    x=75;
    digitalWrite(roLeK, HIGH);
    digitalWrite(roLeY, HIGH);
    digitalWrite(YKLed, LOW);
    digitalWrite(PLed, LOW);
    digitalWrite(kokuM, LOW);
    digitalWrite(roLeP, HIGH);
    for(z=0;z<255;z++)
    {
    leds.setLED(0, { 0, z, 0 });
    leds.setLED(1, { 0, z, 0 });
    leds.setLED(2, { 0, z, 0 });
    leds.setLED(3, { 0, z, 0 });
    leds.setLED(4, { 0, z, 0 });
    leds.setLED(5, { 0, z, 0 });
    leds.setLED(6, { 0, z, 0 });
    leds.setLED(7, { 0, z, 0 });
    leds.setLED(8, { 0, z, 0 });
    leds.setLED(9, { 0, z, 0 });
    leds.update();
    delay(20);
    }
    for(b=255;b>0;b--)
    {
    leds.setLED(0, { 0, b, 0 });
    leds.setLED(1, { 0, b, 0 });
    leds.setLED(2, { 0, b, 0 });
    leds.setLED(3, { 0, b, 0 });
    leds.setLED(4, { 0, b, 0 });
    leds.setLED(5, { 0, b, 0 });
    leds.setLED(6, { 0, b, 0 });
    leds.setLED(7, { 0, b, 0 });
    leds.setLED(8, { 0, b, 0 });
    leds.setLED(9, { 0, b, 0 });
    leds.update();
    delay(20);
    }
    break;
    }
    }
    void bosluk()
    {
   digitalWrite(roLeY, HIGH);
   digitalWrite(roLeK, HIGH);
   digitalWrite(roLeP, HIGH);
   digitalWrite(PLed, LOW);
   leds.setLED(0, { 0, 0, 0 });//WS2801 LED0 off
   leds.setLED(1, { 0, 0, 0 });//WS2801 LED1 off
   leds.setLED(2, { 0, 0, 0 });//WS2801 LED2 off
   leds.setLED(3, { 0, 0, 0 });//WS2801 LED3 off
   leds.setLED(4, { 0, 0, 0 });//WS2801 LED4 off
   leds.setLED(5, { 0, 0, 0 });//WS2801 LED5 off
   leds.setLED(6, { 0, 0, 0 });//WS2801 LED6 off
   leds.setLED(7, { 0, 0, 0 });//WS2801 LED7 off
   leds.setLED(8, { 0, 0, 0 });//WS2801 LED8 off
   leds.setLED(9, { 0, 0, 0 });//WS2801 LED9 off
   leds.update();
   digitalWrite(PLed, LOW);
   digitalWrite(YKLed, LOW);
   digitalWrite(kokuM, LOW);
   x=75;
   delay(1000);
   oy();
    }

bturcan:
I have to count press amounts to each button and then write it to sdcard with 3 different file, like spray.txt,red.txt and green.txt

I may well have missed something but I see nothing in your code that counts button presses.

I reckon you need a function that reads button presses and accumulates the total; another function that calculates the averages at appropriate intervals and a third function that lights up the LEDs based on the data. So the code overall code might be something like this

// global variables

void setup() {
   // read SD card and copy saved values to appropriate variables
   // other stuff
}

void loop() {
   readButtons and update count
   calculate averages and update values that came from SD Card
   save to SD Card ?
   update LEDs base on values
}

Have a look at planning and implementing a program

...R