Project tutorial
Hookah Lighting

Hookah Lighting © GPL3+

Make the cozy shisha nights unforgettable.

  • 10 views
  • 0 comments
  • 0 respects

Components and supplies

Necessary tools and machines

09507 01
Soldering iron (generic)

Apps and online services

About this project

It's an easy way to make the evenings moody. Simple project and girl love it. :D

I also have a remote control, but it works without it.

If you are interested in more interesting projects, then follow me and see my previous projects.

Code

Source codeArduino
#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
#include <avr/power.h>
#endif
#include <IRremote.h>
byte program = 0;
bool onoff = 1; //on
int RECV_PIN = 11;

byte sens = 10;

IRrecv irrecv(RECV_PIN);

decode_results results;
#define PIN 6

byte NUMPIXELS=3;
byte bright=100; //100%
int rVal = 254;
int gVal = 1;
int bVal = 127;

int rDir = -1;
int gDir = 1;
int bDir = -1;
byte last[3]={255,255,255};
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);

int delayval = 10;

void setup() {
  Serial.begin(2000000);
  pinMode(13, OUTPUT); digitalWrite(13, 0);
  irrecv.enableIRIn();
  #if defined (__AVR_ATtiny85__)
    if (F_CPU == 16000000) clock_prescale_set(clock_div_1);
  #endif
  pixels.begin();
}

void loop()
{
  if (program == 0 && onoff == 1)
  {
    rVal = rVal + rDir;
    gVal = gVal + gDir;
    bVal = bVal + bDir;
    if (rVal >= 255 || rVal <= 0) {
      rDir = rDir * -1;
    }

    if (gVal >= 255 || gVal <= 0) {
      gDir = gDir * -1;
    }

    if (bVal >= 255 || bVal <= 0) {
      bDir = bDir * -1;
    }
    byte r, g, b;
    r = rVal; g = gVal; b = bVal;
    Show(r,g,b);
    delay(delayval);
  }
  if (irrecv.decode(&results)) 
  {
    digitalWrite(13, 0);
    Serial.println(results.value);
    switch (results.value)
    {
      case 16748655:    //R
        program = 2;
        Show(255,0,0);
        break;
      case 16769055:    //ON
        bright=100;
        NUMPIXELS=4;
        onoff = 1;
        Show();
        break;
      case 16736415:    //OFF
        onoff = 0;
        Show(0,0,0);
        break;
      case 16716015:    //G
        program = 2;
        Show(0,255,0);
        break;
      case 16732335:    //B
        program = 2;
        Show(0,0,255);
        break;
      case 16764975:    //W
        program = 2;
        Show(255,255,255);
        break;
      case 16773135:    //Flash
        program = 1;
        break;
      case 16767015:    ////Fade
        program = 0;
        break;
      case 16752735:    //brightnes + 
        if(bright<100) bright+=10;
        Show();
        break;
      case 16720095:    //brightnes -
        if(bright>0) bright-=10;
        Show();
        break;
        //////
      //Colors//
        //////
      case 16713975:  //G4
        program = 2;
        Show(0, 255, 255);
        break;
      case 16730295:    //B2
        program = 2;
        Show(255,0,255);
        break;
      case 16746615:    //R4
        program = 2;
        Show(255,255,0);
        break;
      case 16750695:    //Pixels --
          Show(-1);
        break;
      case 16754775:    //Pixels ++
          NUMPIXELS++;
          Show();
        break;
      case 16722135:    //delay++
        delayval++;
        break;
      case 16718055:    //delay --
        if(delayval>0)
          delayval--;
        break;

    }
    irrecv.resume(); // Receive the next value
    digitalWrite(13, 0);
  }
}

void Show(byte _r,byte _g,byte _b)
{
  if((_r+_g+_b)!=0)
  {
    last[0]=_r;
    last[1]=_g;
    last[2]=_b;
  }
  int _i=0; //address
  do
  {
    pixels.setPixelColor(_i, pixels.Color((_r*bright)/100,(_g*bright)/100,(_b*bright)/100));
    _i++;
  }while(_i<NUMPIXELS);
  pixels.show();
}

void Show()
{
  int _i=0; //address
  do
  {
    pixels.setPixelColor(_i, pixels.Color((last[0]*bright)/100, (last[1]*bright)/100, (last[2]*bright)/100));
    _i++;
  }while(_i<NUMPIXELS);
  pixels.show();
}

void Show(int _d)
{
  NUMPIXELS--;
  int _i=0; //address
  do
  {
    pixels.setPixelColor(_i, pixels.Color((last[0]*bright)/100, (last[1]*bright)/100, (last[2]*bright)/100));
    _i++;
  }while(_i<NUMPIXELS);
  pixels.setPixelColor(NUMPIXELS, pixels.Color(0,0,0));
  pixels.show();
}

Schematics

Circuit 1
Circuit neo rekj7mtsjn
circuit 2
The Adafruit NeoPixels
Circ 5k6u8kal21

Comments

Similar projects you might like

SMART Home LED Lighting System and More

Project in progress by Joey Pongallo

  • 6,715 views
  • 5 comments
  • 17 respects

The PerfectAutomatic Lighting System Using Arduino + LDR ...

Project tutorial by Smart Technology

  • 6,069 views
  • 0 comments
  • 11 respects

Kitchen Working Area Automatic Lighting on Arduino

Project tutorial by Vadim

  • 2,071 views
  • 2 comments
  • 5 respects

Solar Powered, Cellar Lighting Arduino Control

Project in progress by TJ Blevins

  • 1,840 views
  • 0 comments
  • 5 respects

Add Animated (Marquee) Lighting to Your Projects

Project tutorial by ericBcreator

  • 2,003 views
  • 5 comments
  • 18 respects

Aquarium Ambience Lighting (LED) Control

Project showcase by randtekk

  • 893 views
  • 1 comment
  • 2 respects
Add projectSign up / Login