Crystal Circular Transparent Lamp

by anastasiapanfil in Circuits > Arduino

316 Views, 2 Favorites, 0 Comments

Crystal Circular Transparent Lamp

proiect v9.png
proiect v9.png
Anastasia si Elena

This project was made by Panfil Anastasia and Bogaci Elena during the GGIT Summer Camp 2021.

Supplies

  • Fusion 360 to model the lamp itself, using the sketches, commands and techniques learned during the GGIT summer camp.
  • Arduino, Tinkercad to develop the electronic part, including the code and diagram, with all its components: 15 white LEDs, 2 RGB LEDs, 21 rezistors: 220 ohmi, 2 pushbuttons, breadboard, Arduino UNO, Dupont Cables M - M, Dupont Cables T - T, Dupont Cables T - M.

Sketching

photo_2021-08-14_00-46-23.jpg
sketch11.jpg
sketch3.jpg
photo_2021-08-14_00-46-20.jpg
sketch2.jpg
sketch4.jpg

The main dimensions were directly determined in the project-making, but overall, the model is about 16x16x16.

3D Modeling

proiect v8.png
proiect v10 vs.png
proiect v10 vw.png
proiect v8 view 1.png

The lamp consists of precise geometric figures, as well as more abstract elements, created with the free hand. It consists of 3 basic parts, the lamp itself, the base (platform) and the lid. The strips arranged in a circular shape are made of see-through plastic. The base has 19 holes, predestined for LEDs. They will be arranged so that the light they emit can be seen from a certain distance. Also, in one part of the base there are 3 holes, a hole for the USB port and two more for pushbuttons, which if pressed activate certain modes. The cover is the most important part, with the entire electronic part: Arduino UNO, breadboard, LEDs, Cables, etc. Both the Arduino board and the breadboard are well fixed, with small walls around each one.

Code & Diagram (Arduino)

photo_2021-08-13_23-25-16.jpg
photo_2021-08-13_23-45-30.jpg
photo_2021-08-13_23-45-33.jpg

The functional part of the current lamp consists of three main aspects.

First of all, it focuses on igniting all of the LEDs. This effect can be achieved by pressing the first button (the one next to the USB port). The first secondary effect is based on the six of the white LEDs connected to the PWM pins of the Arduino UNO. This effect involves six different modes, preceded by a short animation that shows which specific mood is triggered. To activate these moods, press the other button (long press recommended). Most of this mood have a circular pattern. The sixth mood is a random combination of all the previous.

The second effect is based on the RGB LEDs and it is about different color palettes incorporating two colors. The animation includes a gradient slight change from one color to another. The system avail 10 color palettes. The color effect can be appealed by pressing (for a period of approximately 500 microseconds) the first button.

By pressing the first button as well (long - long press) you turn off the lamp.

Also check out the code or click on the file below >>

#include <stdlib.h>     /* srand, rand */
#include <time.h>       /* time */

#define button 4 
#define button2 2 
#define resistor A0 

#define W1 11
#define W2 10
#define W3 9
#define W4 6
#define W5 5
#define W6 3

#define L1 7
#define L2 A1
#define L3 A2
#define L4 A3
#define L5 A4
#define L6 A5
#define L7 13
#define L8 12
#define L9 8

int niv = 15;

bool buttonStatusGlobal = LOW;
bool val = false, val1 = false, yetAnotv = false, colval = false;
bool second_val = false, third_val = false;

int longp = 250;


int pressed = 0;
int released = 0; 
int presstime = 0;

int i;
int time1, time2;
int state = -1;
int state1 = 0;
int j;

void Print(float o, float m, float n, int be)
{
  Serial.print(o);
  Serial.print(" ");
  Serial.print(m);
  Serial.print(" ");
  Serial.print(n);
  Serial.print(" ");
  Serial.println(be);
}

float Contor(float* Color1, float* Color2, int index)
{  
  float x = (Color2[index] - Color1[index]) / niv; 
  return(x);
}

void Direction1(float Color1[], float Color2[], float step[])
{
  float i, j, k;
  i = Color1[0];
  j = Color1[1];
  k = Color1[2];

  analogWrite(W1, round(i));
  analogWrite(W3, round(j));
  analogWrite(W2, round(k));
  
  analogWrite(W4, round(i));
  analogWrite(W6, round(j));
  analogWrite(W5, round(k));
  
  
  for (int a = 1; a <= niv; a++)
  {
    i = i + step[0];
    j = j + step[1];
    k = k + step[2];
    analogWrite(W1, round(i));
    analogWrite(W3, round(j));
    analogWrite(W2, round(k));
    //Print(round(i), round(j), round(k), a);
    analogWrite(W4, round(i));
    analogWrite(W6, round(j));
    analogWrite(W5, round(k));
  }
}

void Direction2(float Color1[], float Color2[], float step[])
{
  float i, j, k;
  i = Color2[0];
  j = Color2[1];
  k = Color2[2];

  analogWrite(W1, round(i));
  analogWrite(W3, round(j));
  analogWrite(W2, round(k));
  
  analogWrite(W4, round(i));
  analogWrite(W6, round(j));
  analogWrite(W5, round(k));
  
  for (int a = 1; a <= niv; a++)
  {
    i = i - step[0];
    j = j - step[1];
    k = k - step[2];
    analogWrite(W1, round(i));
    analogWrite(W3, round(j));
    analogWrite(W2, round(k));
    //Print(round(i), round(j), round(k), a);
    analogWrite(W4, round(i));
    analogWrite(W6, round(j));
    analogWrite(W5, round(k));
  }
}

void Execute_Color(float* Hex1, float* Hex2)
{
  float step[3];
  for (int itter = 0; itter <= 2; itter++)
  {
    step[itter] = Contor(Hex1, Hex2, itter);
  }
  Direction1(Hex1, Hex2, step);
  delay(500);
  Direction2(Hex1, Hex2, step);
  delay(500);
}

void Choose_Color(int comb)
{
  float FFD87F[] = {255, 216, 127};
  float DA668E[] = {218, 102, 142};
  float Sev099CD[] = {112, 153, 205};
   
  float TwoF5B65[] = {47, 91, 101};
  float NinE66CE[] = {158, 102, 206};

  float CE6D66[] = {206, 109, 102};
  float Nul2849E[] = {2, 132, 158};
  
  float SevA1E55[] = {122, 30, 85};
  float A30054[] = {163, 0, 84};
  
  float E09E08[] = {224, 158, 8};
  float B10A99[] = {177, 10, 153};

  float C3D7E1[] = {195, 215, 225};
  float CDB599[] = {205, 181, 153};
  
  float ADEFD1[] = {173, 239, 209};
  float Nul020RF[] = {0, 32, 63};
  
  float Nin90011[] = {153, 0, 17};
  float FCF6F5[] = {252, 246, 245};
  
  float Thr43148[] = {52, 49, 72};
  float D7C49E[] = {215, 196, 158}; 
  
  switch(comb)
  {  
    case 1:
      Execute_Color(FFD87F, DA668E);
      break;
    case 2:
      Execute_Color(DA668E, Sev099CD);
      break;
    case 3:
      Execute_Color(TwoF5B65, NinE66CE);     
      break;
    case 4:
      Execute_Color(CE6D66, Nul2849E);  
      break;
    case 5:
      Execute_Color(SevA1E55, A30054);
      break;
    case 6:
      Execute_Color(E09E08, B10A99);
      break;
    case 7://Louis Blue!
      Execute_Color(CDB599 ,C3D7E1);
      break;
    case 8:
      Execute_Color(Nul020RF, ADEFD1);
      break;
    case 9:
      Execute_Color(Nin90011, FCF6F5);
      break;
    case 10:
      Execute_Color(Thr43148, D7C49E);
      break;
  }
}

int Function(int pin)
{
  if (pin == 0)
  {
    return(0);
  }
  else if ((pin % 6) == 0)
  {
    return(6);
  }
  else
  {
    return(pin % 6);
  }
}

void Lumen(int led, int m, int lum, int time)
{
  int j;
  for (j = 0; j <= m; j++)
  {
    analogWrite(Choose(Function(led + j)), lum);
    delay(time);
  }
}

void Lumos(int pin, int t1)
{
  int j;
  for (j = 0; j <= 255; j++)
  {
    analogWrite(pin, j);
    delay(t1);
  } 
} 

void Nox(int pin, int t1)
{
  int j;
  for (j = 255; j >= 0; j--)
  {
    analogWrite(pin, j);
    delay(t1);
  } 
}

void Lumos_Nox(int pin, int t1, int t2)     
{
  Lumos(pin, t1);
  Nox(pin, t1);
  delay(t2);
}


void Lumos_Solem(int pin, int pin1, int t1)
{
  int j;
  for (j = 0; j <= 255; j++)
  {
    analogWrite(pin, j);
    analogWrite(pin1, j);
    delay(t1);
  } 
} 

void Nox_Solem(int pin, int pin1, int t1)
{
  int j;
  for (j = 255; j >= 0; j--)
  {
    analogWrite(pin, j);
    analogWrite(pin1, j);
    delay(t1);
  } 
}

void Lumos_Nox_Solem(int pin, int pin1, int t1, int t2)     
{
  Lumos_Solem(pin, pin1, t1);
  Nox_Solem(pin, pin1, t1);
  delay(t2);
}

int Choose(int i)
{
  switch(i)
  {
    case 1: 
      return(W1);
      break;
    case 2: 
      return(W2);
      break;
    case 3: 
      return(W3);
      break;
    case 4: 
      return(W4);
      break;
    case 5: 
      return(W5); 
      break;
    case 6: 
      return(W6);
      break;
  }
}

void Mood1() 
{
  Lumen(1, 6, 0, 0);
  i = rand() % 6 + 1;
  time1 = rand() % 10;
  time2 = rand() % 100 + 1;
  Lumos_Nox(Choose(i), time1, time2);
}
  
void Mood2()
{  
  Lumen(1, 6, 255, 0);  
  delay(50);
    
  Lumen(1, 6, 20, 0);  
  delay(70);

  Lumen(1, 6, 100, 0);  
  delay(50);

  Lumen(1, 6, 5, 0);  
  delay(100);
      
  Lumen(1, 6, 155, 0);  
  delay(100);
}

void Mood3()
{
  int i;
  time1 = 1;
  time2 = 0;
  
  for (i = 1; i <= 6; i++)
  {
    //Serial.println(i);
    Lumos(Choose(i), time1);
  } 
}

void Mood4()
{
  time1 = 0.5;
  time2 = 1;
  int j, k, m = 0;
  i = rand() % 6 + 1;
  
  j = i; k = i;
  
  
  while (m <= 3)
  { 
    if (j == k)
    { 
      Lumos_Nox(Choose(j), time1, time2); 
    }
    else 
    {
      if (j == 0)
      {
        j = 6;
      }
      if (k == 7)
      {
        k = 1;
      }
      Lumos_Nox_Solem(Choose(j), Choose(k), time1, time2);
    }
    j--;
    k++;
    m++;
  }
  delay(500);
}

void Mood6()
{
  int j;
  int time1;
  i = rand() % 6 + 1;
  time1 = rand() % 5 + 1;
   
    
  for (j = 0; j <= time1; j++)
  {
    Choose_Mood(i);
  }
  Lumen(1, 6, 0, 0);
  delay(350);
}

void Mood5()
{
  int i = 0;

  for (i = 1; i <= 6; i++)
  {
    Lumen(i, 2, 255, 0);
    delay(300);
    Lumen(i, 2, 0, 0);
    delay(600);
    Lumen(i + 3, 2, 255, 0);
    delay(300);
    Lumen(i + 3, 2, 0, 0);
    delay(600);
  } 
}

void Choose_Mood(int mood)
{
 switch(mood) 
 {
   case 0:
     val1 = true;
     third_val = false;
     break;
   case 1:
     third_val = false;
     Mood1();
     break;
   case 2:
     third_val = false;
     Mood2();
     break;
   case 3: 
     third_val = false;
     Mood3();
     break;
   case 4: 
     third_val = false;
     Mood4();
     break;
   case 5:
     third_val = false;  
     Mood5();
     break;
   case 6:
     third_val = false;
     Mood6();
     break;
   case 7:
     third_val = false;
     val1 = false;
     break;
 }
}
 

void moodNumber(int mood)
{
  if (mood == 0)
  {
  }
  else
  {
    Lumen(0, mood, 255, 100);
    delay(400);
  
    Lumen(0, mood, 0, 0);
    delay(300);
  
    Lumen(0, mood, 255, 0);
    delay(300);
  
    Lumen(0, mood, 0, 0);
    delay(300);
  
    Lumen(0, mood, 255, 0);
    delay(700);
  
    Lumen(0, mood, 0, 0);
  }
}

void Lumos_Maxima(bool st)
{
  digitalWrite(L1, st);
  digitalWrite(L2, st);
  digitalWrite(L3, st);
  digitalWrite(L4, st);
  digitalWrite(L5, st);
  digitalWrite(L6, st); 
  digitalWrite(L7, st);  
  digitalWrite(L8, st);  
  digitalWrite(L9, st);  

}


void setup()
{
  pinMode(W1, OUTPUT);
  pinMode(W2, OUTPUT);
  pinMode(W3, OUTPUT);
  pinMode(W4, OUTPUT);
  pinMode(W5, OUTPUT);
  pinMode(W6, OUTPUT);
  
  pinMode(L1, OUTPUT);
  pinMode(L2, OUTPUT);
  pinMode(L3, OUTPUT);
  pinMode(L4, OUTPUT);
  pinMode(L5, OUTPUT);
  pinMode(L6, OUTPUT);
  
  pinMode(button, INPUT_PULLUP);
  pinMode(button2, INPUT_PULLUP);
  
  Serial.begin(9600);
  srand (time(0));
    
} 


void loop()
{
  bool buttonStatusLocal;
  buttonStatusLocal = digitalRead(button);
  
  if ((buttonStatusLocal == LOW) && (val == false))
  {
    colval = false;
    val = true;
    pressed = millis();
  } 
  else if ((val == true) && (buttonStatusLocal == HIGH))  
  {
    val = false;
    released = millis();
  
  presstime = released - pressed;
  //Serial.println(presstime);
  }  
  
  
 if (presstime > 0)
  {
    Serial.println(presstime);
  }
  
  if ((presstime > longp) && (presstime < (8 * longp)) && (buttonStatusGlobal == true)) 
  {
    Serial.print("COLOR");
    state1++;
    colval = true; 
    second_val = false;
    if (state1 == 11)
    {
      state1 = 1;
    }
    Serial.println(state1);
  }
  else if (presstime > 0)
  {
    buttonStatusGlobal = !buttonStatusGlobal;
    if (buttonStatusGlobal == HIGH) 
    {
      Serial.println("ON");
    }
    else
    {
      Serial.println("OFF");
    } 
  }
  

  
  if(buttonStatusGlobal == HIGH)
  {
    yetAnotv = true;
    Lumos_Maxima(HIGH);
    if (val1 == false)
    {
      Lumen(1, 6, 255, 0);
    }
    if (digitalRead(button2) == LOW)
    {
      colval = false;
      second_val = true;
      third_val = true;
      /*Lumen(1, 6, 0, 0);
      state++;
      if (state == 8)
      {
        state = 1;
      }
      
      delay(550);
      if (state == 7)
      {
        moodNumber(0);
      }  
      else
      {  
        moodNumber(state);
      }
    }
    Choose_Mood(state);
    }
    else if (yetAnotv == true)
    {
      Lumos_Maxima(LOW);
      Lumen(1, 6, 0, 0);*/
    }
  
  if ((second_val == true) && (buttonStatusGlobal == true))
  {
    Lumen(1, 6, 0, 0);
    if (third_val == true)
    {
      state++;
    
      if (state == 8)
      {
      state = 1;
      }
      
      delay(550);
      if (state == 7)
      {
        moodNumber(0);
      }  
      else
      {  
        moodNumber(state);
      }
      }
        Choose_Mood(state);
      }
  }
    else if (yetAnotv == true)
    {
      Lumos_Maxima(LOW);
      Lumen(1, 6, 0, 0);
  }
      
  if ((colval == true) && (buttonStatusGlobal == true))
  {
    Choose_Color(state1);
  } 
  
  presstime = 0;
  
}