DSL810 Assignment5: Input Devices Phone Sensors - Alternative uses of Mobile phone sensors.

Assignment 5

A. What are the different sensors in your phone and what do they do? Conduct an experiment to measure and analyze the data for a sensor in a log and report your findings.
B. Measure something: add a sensor to a microcontroller board and read it. Document the process. Upload the arduino code. Find an application for it in the real world around you. Please write in your own words what did you infer from the datasheet of the input device that you used?

Humidity Sensor (DHT22)

The DHT-22 (also named as AM2302) is a digital-output, relative humidity, and temperature sensor. It uses a capacitive humidity sensor and a thermistor to measure the surrounding air, and sends a digital signal on the data pin.

DHT22 sensor has four terminals (Vcc, DATA, NC, GND), which are connected to the board as follows −
*DATA pin to Arduino pin number 2
*Vcc pin to 5 volt of Arduino board
*GND pin to the ground of Arduino board
*We need to connect 10k ohm resistor (pull up resistor) between the DATA and the Vcc pin.

Technical Details:
*Power − 3-5V
*Max Current − 2.5mA
*Humidity − 0-100%, 2-5% accuracy
*Temperature − 40 to 80°C, ±0.5°C accuracy


Once hardware connections are done, you need to add DHT22 library to your Arduino library file also.

Humidity Sensor Code Only


                  #include "DHT.h"
                  #define DHTPIN 2     
                  #define DHTTYPE DHT22   

                  DHT dht(DHTPIN, DHTTYPE);

                  void setup() {
                    Serial.begin(9600);
                    Serial.println("DHTxx test!");

                    dht.begin();
                  }

                  void loop() {
                    
                    delay(2000);
                    float h = dht.readHumidity();
                    float t = dht.readTemperature();
                    float f = dht.readTemperature(true);

                    if (isnan(h) || isnan(t) || isnan(f)) {
                      Serial.println("Failed to read from DHT sensor!");
                      return;
                    }

                    float hif = dht.computeHeatIndex(f, h);
                    float hic = dht.computeHeatIndex(t, h, false);

                    Serial.print("Humidity: ");
                    Serial.print(h);
                    Serial.print(" %\t");
                    Serial.print("Temperature: ");
                    Serial.print(t);
                    Serial.print(" *C ");
                    Serial.print(f);
                    Serial.print(" *F\t");
                    Serial.print("Heat index: ");
                    Serial.print(hic);
                    Serial.print(" *C ");
                    Serial.print(hif);
                    Serial.println(" *F");
                  }
                

3X3 LED CUBE MAKING

A typical 3*3*3 LED cube connected to UNO is shown in the image above, the cube consists of 27 Light Emitting Diodes, these 27 LEDs are arranged in rows and columns forming a cube.
There are many types of cubes that can be designed. The simplest one is 3x3x3 LED cube. For 4*4*4 LED cube the work almost triples because you need to do work for 64 LEDs. With each higher number, the work almost doubles or triples. But every cube more or less works on the same way.
3x3x3 LED cube is simplest because there are some advantages to this design like,
For this cube you need not to worry about power consumption or dissipation.
Low Power supply demand.
We don’t need any switching electronics for this cube.
We need lesser logic terminals so we don’t need shift registers or anything like that.
We need not worry about power drawn by LED because the LED usually stated to work at 20mA current but that is wrong, that number provides the maximum current allowed through the LED. Normally an LED works well from 2mA to 5mA. Anything higher than that, the LED will heat intensely and it will burn out.
So we can drive 9 LEDs carrying 2mA current from a single pin of UNO with no problems. The UNO pins are capable of delivering 20-30mA.
For the cube I chose clear white LED, because I have them spare. You can choose any LED type or color of your choice, but the LED with colored shall work great for this projects.
For the cube we need to spare 12 pins of UNO.
Components Required:
ARDUINO UNO, 220Ω resisters (3 pieces), , power supply (5v),
27 white LEDs, Breadboard wire,
Soldering Iron, Soldering wire and flux,
SR2032 button cell, Some tools,
And a empty cardboard box, pencil, ruler and some jumpers.
Building the Arduino 3x3x3 LED Cube:
Step 1: At first we need to check each LED, once the cube is done if there is any faulty LED present in the cube it would be very difficult to replace, so first we need to check each LED.
This is done by button cell SR2032, it’s a lithium ion battery that has a terminal voltage of 3V it is perfect for checking LED, and one can also use MULTIMETER to check the LED.
After confirming all the 27 LEDs are working keep it aside and lets move one to next step.
Step 2: Now take the breadboard wire and peel the layer off the conductor, we can use any wire but breadboard connecting wires works great. After peeling off we will have something as shown in above figure, cut the conductor wire in a length of 7cm and continue the process until we have six 7cm conducting wires (figure below). These wires are used for bridging the LED layers, we will get to this point shortly.
Step 3: Now we need to take the empty card board box and stick a white paper on top, as shown in the figure. The paper is just for marking the points clearly, there is no specific use for it. Just use cello tape or glue at the corners for holding the paper in place while marking and drilling the holes.
After that take pencil and scale, mark nine points on paper each 2cm apart forming a structure of cube as shown in below figure.
Here we are using 2cm because; the negative terminal of LED is of length 2.5cm. So with 2cm apart, we will have 5mm for soldering one LED to another. Any length higher from it, the LED terminals soldering becomes troubling, with lower length the cube looks very clumsy after finishing. So 2cm would be very appropriate.
After that take a pointy object like a pencil or a pen and poke a hole at each point, make sure you poke a hole just about the size of LED, first poke one hole take the LED fit it in, the LED should not fall through the hole nor the LED should the too tight. While soldering the pins we don’t the LED to move so it should not be lose. If the LED is fitted in the hole too tight we cannot wiggle it out easily, so each time you poke a hole, check it with the LED.
Step 4: After that, place a LED in one of the hole and bend the positive terminal as shown in below figure.
After that, the positive pin should again be bent to form a ‘L’ shape. On close look one can see a small notch on the terminal of LED near the tip, which is where you should bend for ‘L’ shape. After that, bend the negative terminal to the right. This is shown in figure:
Step 5: The very same way bend three LEDs and arrange them in a row as shown below, this pattern is used throughout the design and there would be no further changes. For more convenience one can bend all the 27 LEDs as done for first one and then can be proceed to the arranging and soldering.
Now bend all the remaining 24 LEDs in the same way as described above, nine of them are bent in the form of a matrix as shown below,
Step 6: After that solder all the negative joints, this results in three negative terminals, each representing one row. This is shown below.
After that take two conductors wires which we stripped and place them as shown in the figure and solder the six joints of conductor forming a complete matrix.
Now all the negative terminals of nine LEDs are connected to each other with this we will have 9 positive terminals (CP1-CP9) and one negative terminal (CN1). After carefully wiggling out the layer one we will have a setup as shown below. Cutoff the extra ends and we will have one layer of LED cube.
Step 7: Now we have one of three layers of cubes, we need to develop another two layers by following the same procedure as done for this one. Second and third layer are shown below:
Step 8: Now we have all the three layers needed to make the LED cube, we are going to stack one over the other to form a cube.
First we take layer1 and layer 2, mount them one over the other. Solder all the common positive representing terminals. This is shown in figure. For instance CP1 of first layer is soldered to CP1 of second layer; CP2 of first layer is soldered to CP2 of second layer and so on. Here we will slide the layers about 5mm, one top over the other, first we need to solder the ends of the layers so that it holds in place and for the layers to be aligned. After that, carefully solder the other terminals. After soldering we will have, Now we will stack the third and final layer of cube, with this we have completed the cube. The soldering of third layer would be a bit difficult, as the cube terminal be sensitive, if the terminals are wiggled too much, a joint might break internally and soldering an internal joint would be impossible, until the cube is break down. So one should check every joint twice proceeding to the next one.
While soldering cube terminals, the temperature of LED should be kept in mind, if the soldering iron is kept close to LED more than 5 sec, the LED will burn down and replacing it would be a pain, so one should pay attention while soldering the LEDs.

Circuit and Working Explanation


With the cube complete, we have a total of 12 pins. Over which nine are common positive and three are common negative. Each common positive terminal connects the positive terminals of three LEDs and each common negative terminal connects the negative terminals of nine LEDs. So we have nine columns represent the nine positive terminals (CP1-CP9) and three layers represent the three negative terminals (CN1-CN3).
PIN2 ------------------CP1 (Common Positive)
PIN3 ------------------CP2 (Common Positive)
PIN4 ------------------CP3 (Common Positive)
PIN5 ------------------CP4 (Common Positive)
PIN6 ------------------CP5 (Common Positive)
PIN7 ------------------CP6 (Common Positive)
PIN8 ------------------CP7 (Common Positive)
PIN9 ------------------CP8 (Common Positive)
PIN10 ----------------CP9 (Common Positive)
PIN A0 ------------------CN1 (Common Negative)
PIN A1 ------------------CN2 (Common Negative)
PIN A2 ------------------CN3 (Common Negative)
Now, we will connect these 12 pins to the UNO appropriately as shown in the circuit diagram for arduino based LED cube below.

3X3 led cube Code


                  void setup()
                  {
                      for (int i=0;i<11;i++)
                      {
                          pinMode(i,OUTPUT);    // PINs2-10 are set as output
                      }
                      pinMode(A2,OUTPUT);    //PIN A0 set as output
                     pinMode(A1,OUTPUT);   // PIN A1 set as output
                      pinMode(A0,OUTPUT);   // PIN A2 set as output
                      
                      digitalWrite(A0,HIGH);    //pull up the A0 pin
                      digitalWrite(A1,HIGH);   // pull up the A1 pin
                      digitalWrite(A2,HIGH);   // pull up the A2 pin

                        /* add setup code here, setup code runs once when the processor starts */

                  }

                  void loop()
                  {
                          digitalWrite(A0,LOW);    //layer 1 of cube is grounded
                            for (int i=2;i<11;i++)
                            {
                                digitalWrite(i,HIGH);    //turn ON each LED one after another in layer1
                                delay(200);
                                  delay(200);
                                    delay(200);
                              digitalWrite(i,LOW);
                            }
                          digitalWrite(A0,HIGH);    //layer1 is pulled up
                            
                            digitalWrite(A1,LOW);   // layer 2 of cube is grounded
                            for (int i=2;i<11;i++)
                            {
                                digitalWrite(i,HIGH);   // turn ON each LED one after another in layer2
                                              delay(200);
                                              delay(200);
                                              delay(200);
                                digitalWrite(i,LOW);
                            }
                          digitalWrite(A1,HIGH);    // layer2 is pulled up
                            
                          digitalWrite(A2,LOW);    // layer 3 of cube is grounded
                          for (int i=2;i<11;i++)
                          {
                              digitalWrite(i,HIGH);    // turn ON each LED one after another in layer3
                                            delay(200);
                                            delay(200);
                                            delay(200);
                              digitalWrite(i,LOW);
                          }
                          digitalWrite(A2,HIGH);    // layer3 is pulled up

                  }
                


LED Cube Making



LED Matrix code


CODE



                                                  /*
                            - Arduino & Chralieplexing
                            - Driving 9 LEDs using only 4 I/O Pins
                            - Tri-State Logic Implementation
                            - Code written by Ganesh Ram
                            - Modified from code by T.K.Hareendran
                            - Tested at Department of Design

                            */

                            #define LED_1 4
                            #define LED_2 5
                            #define LED_3 6
                            #define LED_4 7
                            #define buttonApin 11
                            #define buttonBpin 12
                            int i=0;
                            char input;
                            void setup()
                            {
                               pinMode(LED_1, INPUT);
                               pinMode(LED_2, INPUT);
                               pinMode(LED_3, INPUT);
                               pinMode(LED_4, INPUT);
                               pinMode(buttonApin, INPUT_PULLUP);
                               pinMode(buttonBpin, INPUT_PULLUP);
                               Serial.begin(9600);
                            }

                            void loop()
                            {

                               if (digitalRead(buttonApin) == LOW)
                            {
                               {
                                for(i=0;i<=50;i++)
                                I();

                                for(i=0;i<50;i++)
                                alloff();
                                  
                                for(i=0;i<=50;i++)
                                I();

                                for(i=0;i<50;i++)
                                alloff();

                                for(i=0;i<=50;i++)
                                T();

                                for(i=0;i<50;i++)
                                alloff();

                                for(i=0;i<=50;i++)
                                D();

                                for(i=0;i<50;i++)
                                alloff();
                                
                               
                              }


                            }

                               if (digitalRead(buttonBpin) == LOW)
                              {
                                for(int n= 0; n<5; n++)
                                {
                                  for(i=0;i<50;i++)
                                  allon();

                                  for(i=0;i<50;i++)
                                  alloff();

                                }
                              }

                               
                               if (Serial.available()) {
                                input = Serial.read();//read the input
                                if (input == 'a' || input == 'A') 
                                {
                                  for(i=0;i<=50;i++)
                                   {
                                      A();
                                   }
                                }

                                if (input == 'b' || input == 'B') 
                                {
                                  for(i=0;i<=50;i++)
                                   {
                                      B();
                                   }
                                }

                                if (input == 'c' || input == 'C') 
                                {
                                  for(i=0;i<=50;i++)
                                   {
                                      C();
                                   }
                                }

                                 if (input == 'd' || input == 'D') 
                                {
                                  for(i=0;i<=50;i++)
                                   {
                                      D();
                                   }
                                }

                                 if (input == 'e' || input == 'E') 
                                {
                                  for(i=0;i<=50;i++)
                                   {
                                      E();
                                   }
                                }

                                 if (input == 'f' || input == 'F') 
                                {
                                  for(i=0;i<=50;i++)
                                   {
                                      F1();
                                   }
                                }

                                 if (input == 'g' || input == 'G') 
                                {
                                  for(i=0;i<=50;i++)
                                   {
                                      G();
                                   }
                                }

                                 if (input == 'h' || input == 'H') 
                                {
                                  for(i=0;i<=50;i++)
                                   {
                                      H();
                                   }
                                }

                                 if (input == 'i' || input == 'I') 
                                {
                                  for(i=0;i<=50;i++)
                                   {
                                      I();
                                   }
                                }

                                 if (input == 'j' || input == 'J') 
                                {
                                  for(i=0;i<=50;i++)
                                   {
                                      J();
                                   }
                                }

                                 if (input == 'k' || input == 'K') 
                                {
                                  for(i=0;i<=50;i++)
                                   {
                                      K();
                                   }
                                }

                                 if (input == 'l' || input == 'L') 
                                {
                                  for(i=0;i<=50;i++)
                                   {
                                      L();
                                   }
                                }

                                 if (input == 'm' || input == 'M') 
                                {
                                  for(i=0;i<=50;i++)
                                   {
                                      M();
                                   }
                                }

                                 if (input == 'n' || input == 'N') 
                                {
                                  for(i=0;i<=50;i++)
                                   {
                                      N();
                                   }
                                }

                                 if (input == 'o' || input == 'O') 
                                {
                                  for(i=0;i<=50;i++)
                                   {
                                      O();
                                   }
                                }

                                 if (input == 'p' || input == 'P') 
                                {
                                  for(i=0;i<=50;i++)
                                   {
                                      P();
                                   }
                                }

                                 if (input == 'q' || input == 'Q') 
                                {
                                  for(i=0;i<=50;i++)
                                   {
                                      Q();
                                   }
                                }

                                 if (input == 'r' || input == 'R') 
                                {
                                  for(i=0;i<=50;i++)
                                   {
                                      R();
                                   }
                                }

                                 if (input == 's' || input == 'S') 
                                {
                                  for(i=0;i<=50;i++)
                                   {
                                      S();
                                   }
                                }

                                 if (input == 't' || input == 'T') 
                                {
                                  for(i=0;i<=50;i++)
                                   {
                                      T();
                                   }
                                }

                                 if (input == 'u' || input == 'U') 
                                {
                                  for(i=0;i<=50;i++)
                                   {
                                      U();
                                   }
                                }
                                 if (input == 'v' || input == 'V') 
                                {
                                  for(i=0;i<=50;i++)
                                   {
                                      V();
                                   }
                                }

                                 if (input == 'w' || input == 'W') 
                                {
                                  for(i=0;i<=50;i++)
                                   {
                                      W();
                                   }
                                }

                                 if (input == 'x' || input == 'X') 
                                {
                                  for(i=0;i<=50;i++)
                                   {
                                      X();
                                   }
                                }

                                 if (input == 'y' || input == 'Y') 
                                {
                                  for(i=0;i<=50;i++)
                                   {
                                      Y();
                                   }
                                }

                                 if (input == 'z' || input == 'Z') 
                                {
                                  for(i=0;i<=50;i++)
                                   {
                                      Z();
                                   }
                                }

                                 Serial.println (input);//print the latter saved in the input var

                               } 

                            /*   set_pins(LED_1, LED_2); //LED 1A
                               delay(100);                
                               set_pins(LED_2, LED_1); //LED 1B
                               delay(100);
                              set_pins(LED_1, LED_4);  //LED 1C
                               delay(100);
                               set_pins(LED_4, LED_1); //LED 2C
                               delay(100);
                               set_pins(LED_3, LED_2); //LED 2B
                               delay(100);
                               set_pins(LED_2, LED_3); //LED 2A
                               delay(100); 
                               set_pins(LED_2, LED_4); //LED 3C
                               delay(100);
                               set_pins(LED_3, LED_4); //LED 3B
                               delay(100);
                               set_pins(LED_4, LED_3); //LED 3A
                               delay(100); */

                               
                            }

                            void set_pins(int high_pin, int low_pin)
                            {
                               reset_pins();
                               pinMode(high_pin, OUTPUT);
                               pinMode(low_pin, OUTPUT);
                               digitalWrite(high_pin, HIGH);
                               digitalWrite(low_pin,LOW);
                            }

                            void reset_pins()
                            {
                               pinMode(LED_1, INPUT); 
                               pinMode(LED_2, INPUT);
                               pinMode(LED_3, INPUT);
                               pinMode(LED_4, INPUT);
                               digitalWrite(LED_1, LOW);
                               digitalWrite(LED_2, LOW);
                               digitalWrite(LED_3, LOW);
                               digitalWrite(LED_4, LOW);
                            }

                            void A()
                            {

                               

                               set_pins(LED_1, LED_2); //LED 1A
                               delay(2);                
                               set_pins(LED_2, LED_1); //LED 1B
                               delay(2);
                               set_pins(LED_1, LED_4);  //LED 1C
                               delay(2);
                               set_pins(LED_4, LED_1); //LED 2C
                               delay(2);
                             //  set_pins(LED_3, LED_2); //LED 2B
                               delay(2); 
                               set_pins(LED_2, LED_3); //LED 2A
                               delay(2); 
                               set_pins(LED_2, LED_4); //LED 3C
                               delay(2);
                              // set_pins(LED_3, LED_4); //LED 3B
                               delay(2); 
                               set_pins(LED_4, LED_3); //LED 3A
                               delay(2); 
                               
                             
                            }

                            void B()
                            {

                              set_pins(LED_1, LED_2); //LED 1A
                               delay(2);                
                               set_pins(LED_2, LED_1); //LED 1B
                               delay(2);
                             // set_pins(LED_1, LED_4);  //LED 1C
                               delay(2); 
                               set_pins(LED_4, LED_1); //LED 2C
                               delay(2);
                               set_pins(LED_3, LED_2); //LED 2B
                               delay(2); 
                               set_pins(LED_2, LED_3); //LED 2A
                               delay(2); 
                               set_pins(LED_2, LED_4); //LED 3C
                               delay(2);
                               set_pins(LED_3, LED_4); //LED 3B
                               delay(2); 
                               set_pins(LED_4, LED_3); //LED 3A
                               delay(2); 
                               
                              
                            }


                            void C()
                            {

                               set_pins(LED_1, LED_2); //LED 1A
                               delay(2);                
                               set_pins(LED_2, LED_1); //LED 1B
                               delay(2);
                               set_pins(LED_1, LED_4);  //LED 1C
                               delay(2); 
                              // set_pins(LED_4, LED_1); //LED 2C
                               delay(2);
                             //  set_pins(LED_3, LED_2); //LED 2B
                               delay(2); 
                               set_pins(LED_2, LED_3); //LED 2A
                               delay(2); 
                               set_pins(LED_2, LED_4); //LED 3C
                               delay(2);
                               set_pins(LED_3, LED_4); //LED 3B
                               delay(2); 
                               set_pins(LED_4, LED_3); //LED 3A
                               delay(2); 
                               
                              
                            }

                            void D()
                            {

                              set_pins(LED_1, LED_2); //LED 1A
                               delay(2);                
                               set_pins(LED_2, LED_1); //LED 1B
                               delay(2);
                             // set_pins(LED_1, LED_4);  //LED 1C
                               delay(2); 
                               set_pins(LED_4, LED_1); //LED 2C
                               delay(2);
                             //  set_pins(LED_3, LED_2); //LED 2B
                               delay(2); 
                               set_pins(LED_2, LED_3); //LED 2A
                               delay(2); 
                             //  set_pins(LED_2, LED_4); //LED 3C
                               delay(2);
                               set_pins(LED_3, LED_4); //LED 3B
                               delay(2); 
                               set_pins(LED_4, LED_3); //LED 3A
                               delay(2); 
                               
                              
                            }

                            void E()
                            {

                               set_pins(LED_1, LED_2); //LED 1A
                               delay(2);                
                               set_pins(LED_2, LED_1); //LED 1B
                               delay(2);
                               set_pins(LED_1, LED_4);  //LED 1C
                               delay(2); 
                              // set_pins(LED_4, LED_1); //LED 2C
                               delay(2);
                               set_pins(LED_3, LED_2); //LED 2B
                               delay(2); 
                               set_pins(LED_2, LED_3); //LED 2A
                               delay(2); 
                               set_pins(LED_2, LED_4); //LED 3C
                               delay(2);
                               set_pins(LED_3, LED_4); //LED 3B
                               delay(2); 
                               set_pins(LED_4, LED_3); //LED 3A
                               delay(2); 
                               
                              
                            }

                            void F1()
                            {

                              set_pins(LED_1, LED_2); //LED 1A
                               delay(2);                
                               set_pins(LED_2, LED_1); //LED 1B
                               delay(2);
                               set_pins(LED_1, LED_4);  //LED 1C
                               delay(2); 
                             //  set_pins(LED_4, LED_1); //LED 2C
                               delay(2);
                               set_pins(LED_3, LED_2); //LED 2B
                               delay(2); 
                               set_pins(LED_2, LED_3); //LED 2A
                               delay(2); 
                             //  set_pins(LED_2, LED_4); //LED 3C
                               delay(2);
                            //   set_pins(LED_3, LED_4); //LED 3B
                               delay(2); 
                               set_pins(LED_4, LED_3); //LED 3A
                               delay(2); 
                               
                              
                            }

                            void G()
                            {

                              set_pins(LED_1, LED_2); //LED 1A
                               delay(2);                
                               set_pins(LED_2, LED_1); //LED 1B
                               delay(2);
                             // set_pins(LED_1, LED_4);  //LED 1C
                               delay(2); 
                               set_pins(LED_4, LED_1); //LED 2C
                               delay(2);
                             //  set_pins(LED_3, LED_2); //LED 2B
                               delay(2); 
                               set_pins(LED_2, LED_3); //LED 2A
                               delay(2); 
                               set_pins(LED_2, LED_4); //LED 3C
                               delay(2);
                               set_pins(LED_3, LED_4); //LED 3B
                               delay(2); 
                               set_pins(LED_4, LED_3); //LED 3A
                               delay(2); 
                               
                              
                            }

                            void H()
                            {

                               set_pins(LED_1, LED_2); //LED 1A
                               delay(2);                
                             //  set_pins(LED_2, LED_1); //LED 1B
                               delay(2);
                               set_pins(LED_1, LED_4);  //LED 1C
                               delay(2); 
                               set_pins(LED_4, LED_1); //LED 2C
                               delay(2);
                               set_pins(LED_3, LED_2); //LED 2B
                               delay(2); 
                               set_pins(LED_2, LED_3); //LED 2A
                               delay(2); 
                               set_pins(LED_2, LED_4); //LED 3C
                               delay(2);
                              // set_pins(LED_3, LED_4); //LED 3B
                               delay(2); 
                               set_pins(LED_4, LED_3); //LED 3A
                               delay(2); 
                               
                              
                            }

                            void I()
                            {

                              set_pins(LED_1, LED_2); //LED 1A
                               delay(2);                
                               set_pins(LED_2, LED_1); //LED 1B
                               delay(2);
                               set_pins(LED_1, LED_4);  //LED 1C
                               delay(2); 
                              // set_pins(LED_4, LED_1); //LED 2C
                               delay(2);
                               set_pins(LED_3, LED_2); //LED 2B
                               delay(2); 
                             //  set_pins(LED_2, LED_3); //LED 2A
                               delay(2); 
                               set_pins(LED_2, LED_4); //LED 3C
                               delay(2);
                               set_pins(LED_3, LED_4); //LED 3B
                               delay(2); 
                               set_pins(LED_4, LED_3); //LED 3A
                               delay(2); 
                               
                              
                            }

                            void J()
                            {

                               //set_pins(LED_1, LED_2); //LED 1A
                               delay(2);                
                              // set_pins(LED_2, LED_1); //LED 1B
                               delay(2);
                               set_pins(LED_1, LED_4);  //LED 1C
                               delay(2); 
                               set_pins(LED_4, LED_1); //LED 2C
                               delay(2);
                              // set_pins(LED_3, LED_2); //LED 2B
                               delay(2); 
                              // set_pins(LED_2, LED_3); //LED 2A
                               delay(2); 
                               set_pins(LED_2, LED_4); //LED 3C
                               delay(2);
                               set_pins(LED_3, LED_4); //LED 3B
                               delay(2); 
                               set_pins(LED_4, LED_3); //LED 3A
                               delay(2); 
                               
                              
                            }

                            void K()
                            {

                              set_pins(LED_1, LED_2); //LED 1A
                               delay(2);                
                              // set_pins(LED_2, LED_1); //LED 1B
                               delay(2);
                               set_pins(LED_1, LED_4);  //LED 1C
                               delay(2); 
                              // set_pins(LED_4, LED_1); //LED 2C
                               delay(2);
                               set_pins(LED_3, LED_2); //LED 2B
                               delay(2); 
                               set_pins(LED_2, LED_3); //LED 2A
                               delay(2); 
                               set_pins(LED_2, LED_4); //LED 3C
                               delay(2);
                             //  set_pins(LED_3, LED_4); //LED 3B
                               delay(2); 
                               set_pins(LED_4, LED_3); //LED 3A
                               delay(2); 
                               
                              
                            }

                            void L()
                            {

                              set_pins(LED_1, LED_2); //LED 1A
                               delay(2);                
                             //  set_pins(LED_2, LED_1); //LED 1B
                               delay(2);
                             // set_pins(LED_1, LED_4);  //LED 1C
                               delay(2); 
                             // set_pins(LED_4, LED_1); //LED 2C
                               delay(2);
                             //  set_pins(LED_3, LED_2); //LED 2B
                               delay(2); 
                               set_pins(LED_2, LED_3); //LED 2A
                               delay(2); 
                               set_pins(LED_2, LED_4); //LED 3C
                               delay(2);
                               set_pins(LED_3, LED_4); //LED 3B
                               delay(2); 
                               set_pins(LED_4, LED_3); //LED 3A
                               delay(2); 
                               
                              
                            }

                            void M()
                            {

                              set_pins(LED_1, LED_2); //LED 1A
                               delay(2);                
                              // set_pins(LED_2, LED_1); //LED 1B
                               delay(2);
                               set_pins(LED_1, LED_4);  //LED 1C
                               delay(2); 
                              // set_pins(LED_4, LED_1); //LED 2C
                               delay(2);
                               set_pins(LED_3, LED_2); //LED 2B
                               delay(2); 
                              // set_pins(LED_2, LED_3); //LED 2A
                               delay(2); 
                               set_pins(LED_2, LED_4); //LED 3C
                               delay(2);
                               set_pins(LED_3, LED_4); //LED 3B
                               delay(2); 
                               set_pins(LED_4, LED_3); //LED 3A
                               delay(2); 
                               
                              
                            }

                            void N()
                            {

                               set_pins(LED_1, LED_2); //LED 1A
                               delay(2);                
                              // set_pins(LED_2, LED_1); //LED 1B
                               delay(2);
                               set_pins(LED_1, LED_4);  //LED 1C
                               delay(2); 
                               set_pins(LED_4, LED_1); //LED 2C
                               delay(2);
                               set_pins(LED_3, LED_2); //LED 2B
                               delay(2); 
                               set_pins(LED_2, LED_3); //LED 2A
                               delay(2); 
                               set_pins(LED_2, LED_4); //LED 3C
                               delay(2);
                               set_pins(LED_3, LED_4); //LED 3B
                               delay(2); 
                               set_pins(LED_4, LED_3); //LED 3A
                               delay(2); 
                               
                              
                            }

                            void O()
                            {

                              set_pins(LED_1, LED_2); //LED 1A
                               delay(2);                
                               set_pins(LED_2, LED_1); //LED 1B
                               delay(2);
                               set_pins(LED_1, LED_4);  //LED 1C
                               delay(2); 
                               set_pins(LED_4, LED_1); //LED 2C
                               delay(2);
                             //set_pins(LED_3, LED_2); //LED 2B
                               delay(2); 
                               set_pins(LED_2, LED_3); //LED 2A
                               delay(2); 
                               set_pins(LED_2, LED_4); //LED 3C
                               delay(2);
                               set_pins(LED_3, LED_4); //LED 3B
                               delay(2); 
                               set_pins(LED_4, LED_3); //LED 3A
                               delay(2); 
                               
                              
                            }

                            void P()
                            {

                              set_pins(LED_1, LED_2); //LED 1A
                               delay(2);                
                               set_pins(LED_2, LED_1); //LED 1B
                               delay(2);
                               set_pins(LED_1, LED_4);  //LED 1C
                               delay(2); 
                               set_pins(LED_4, LED_1); //LED 2C
                               delay(2);
                               set_pins(LED_3, LED_2); //LED 2B
                               delay(2); 
                               set_pins(LED_2, LED_3); //LED 2A
                               delay(2); 
                             //  set_pins(LED_2, LED_4); //LED 3C
                               delay(2);
                             //  set_pins(LED_3, LED_4); //LED 3B
                               delay(2); 
                               set_pins(LED_4, LED_3); //LED 3A
                               delay(2); 
                               
                              
                            }

                            void Q()
                            {

                               set_pins(LED_1, LED_2); //LED 1A
                               delay(2);                
                               set_pins(LED_2, LED_1); //LED 1B
                               delay(2);
                              // set_pins(LED_1, LED_4);  //LED 1C
                               delay(2); 
                              // set_pins(LED_4, LED_1); //LED 2C
                               delay(2);
                               set_pins(LED_3, LED_2); //LED 2B
                               delay(2); 
                               set_pins(LED_2, LED_3); //LED 2A
                               delay(2); 
                               set_pins(LED_2, LED_4); //LED 3C
                               delay(2);
                             //  set_pins(LED_3, LED_4); //LED 3B
                               delay(2); 
                             //  set_pins(LED_4, LED_3); //LED 3A
                               delay(2); 
                               
                              
                            }

                            void R()
                            {

                               set_pins(LED_1, LED_2); //LED 1A
                               delay(2);                
                               set_pins(LED_2, LED_1); //LED 1B
                               delay(2);
                               set_pins(LED_1, LED_4);  //LED 1C
                               delay(2); 
                              // set_pins(LED_4, LED_1); //LED 2C
                               delay(2);
                              // set_pins(LED_3, LED_2); //LED 2B
                               delay(2); 
                               set_pins(LED_2, LED_3); //LED 2A
                               delay(2); 
                             //  set_pins(LED_2, LED_4); //LED 3C
                               delay(2);
                              // set_pins(LED_3, LED_4); //LED 3B
                               delay(2); 
                               set_pins(LED_4, LED_3); //LED 3A
                               delay(2); 
                               
                              
                            }

                            void S()
                            {

                               //set_pins(LED_1, LED_2); //LED 1A
                               delay(2);                
                               set_pins(LED_2, LED_1); //LED 1B
                               delay(2);
                               set_pins(LED_1, LED_4);  //LED 1C
                               delay(2); 
                               //set_pins(LED_4, LED_1); //LED 2C
                               delay(2);
                               set_pins(LED_3, LED_2); //LED 2B
                               delay(2); 
                               //set_pins(LED_2, LED_3); //LED 2A
                               delay(2); 
                               //set_pins(LED_2, LED_4); //LED 3C
                               delay(2);
                               set_pins(LED_3, LED_4); //LED 3B
                               delay(2); 
                               set_pins(LED_4, LED_3); //LED 3A
                               delay(2); 
                               
                              
                            }

                            void T()
                            {

                              set_pins(LED_1, LED_2); //LED 1A
                               delay(2);                
                               set_pins(LED_2, LED_1); //LED 1B
                               delay(2);
                               set_pins(LED_1, LED_4);  //LED 1C
                               delay(2); 
                               //set_pins(LED_4, LED_1); //LED 2C
                               delay(2);
                               set_pins(LED_3, LED_2); //LED 2B
                               delay(2); 
                               //set_pins(LED_2, LED_3); //LED 2A
                               delay(2); 
                               //set_pins(LED_2, LED_4); //LED 3C
                               delay(2);
                               set_pins(LED_3, LED_4); //LED 3B
                               delay(2); 
                               //set_pins(LED_4, LED_3); //LED 3A
                               delay(2); 
                               
                              
                            }

                            void U()
                            {

                              set_pins(LED_1, LED_2); //LED 1A
                               delay(2);                
                               //set_pins(LED_2, LED_1); //LED 1B
                               delay(2);
                               set_pins(LED_1, LED_4);  //LED 1C
                               delay(2); 
                               set_pins(LED_4, LED_1); //LED 2C
                               delay(2);
                               //set_pins(LED_3, LED_2); //LED 2B
                               delay(2); 
                               set_pins(LED_2, LED_3); //LED 2A
                               delay(2); 
                               set_pins(LED_2, LED_4); //LED 3C
                               delay(2);
                               set_pins(LED_3, LED_4); //LED 3B
                               delay(2); 
                               set_pins(LED_4, LED_3); //LED 3A
                               delay(2); 
                               
                              
                            }

                            void V()
                            {

                              set_pins(LED_1, LED_2); //LED 1A
                               delay(2);                
                              // set_pins(LED_2, LED_1); //LED 1B
                               delay(2);
                               set_pins(LED_1, LED_4);  //LED 1C
                               delay(2); 
                               set_pins(LED_4, LED_1); //LED 2C
                               delay(2);
                              // set_pins(LED_3, LED_2); //LED 2B
                               delay(2); 
                               set_pins(LED_2, LED_3); //LED 2A
                               delay(2); 
                             //  set_pins(LED_2, LED_4); //LED 3C
                               delay(2);
                               set_pins(LED_3, LED_4); //LED 3B
                               delay(2); 
                              // set_pins(LED_4, LED_3); //LED 3A
                               delay(2); 
                               
                              
                            }

                            void W()
                            {

                             // set_pins(LED_1, LED_2); //LED 1A
                               delay(2);                
                             //  set_pins(LED_2, LED_1); //LED 1B
                               delay(2);
                               set_pins(LED_1, LED_4);  //LED 1C
                               delay(2); 
                              // set_pins(LED_4, LED_1); //LED 2C
                               delay(2);
                               set_pins(LED_3, LED_2); //LED 2B
                               delay(2); 
                               set_pins(LED_2, LED_3); //LED 2A
                               delay(2); 
                               set_pins(LED_2, LED_4); //LED 3C
                               delay(2);
                               set_pins(LED_3, LED_4); //LED 3B
                               delay(2); 
                               set_pins(LED_4, LED_3); //LED 3A
                               delay(2); 
                               
                              
                            }

                            void X()
                            {

                               set_pins(LED_1, LED_2); //LED 1A
                               delay(2);                
                             //  set_pins(LED_2, LED_1); //LED 1B
                               delay(2);
                              set_pins(LED_1, LED_4);  //LED 1C
                               delay(2); 
                             //  set_pins(LED_4, LED_1); //LED 2C
                               delay(2);
                               set_pins(LED_3, LED_2); //LED 2B
                               delay(2); 
                              // set_pins(LED_2, LED_3); //LED 2A
                               delay(2); 
                               set_pins(LED_2, LED_4); //LED 3C
                               delay(2);
                             //  set_pins(LED_3, LED_4); //LED 3B
                               delay(2); 
                               set_pins(LED_4, LED_3); //LED 3A
                               delay(2); 
                               
                              
                            }

                            void Y()
                            {

                              set_pins(LED_1, LED_2); //LED 1A
                               delay(2);                
                              // set_pins(LED_2, LED_1); //LED 1B
                               delay(2);
                              set_pins(LED_1, LED_4);  //LED 1C
                               delay(2); 
                              // set_pins(LED_4, LED_1); //LED 2C
                               delay(2);
                               set_pins(LED_3, LED_2); //LED 2B
                               delay(2); 
                              // set_pins(LED_2, LED_3); //LED 2A
                               delay(2); 
                              // set_pins(LED_2, LED_4); //LED 3C
                               delay(2);
                               set_pins(LED_3, LED_4); //LED 3B
                               delay(2); 
                             //  set_pins(LED_4, LED_3); //LED 3A
                               delay(2); 
                               
                              
                            }

                            void Z()
                            {

                              set_pins(LED_1, LED_2); //LED 1A
                               delay(2);                
                               set_pins(LED_2, LED_1); //LED 1B
                               delay(2);
                               set_pins(LED_1, LED_4);  //LED 1C
                               delay(2); 
                              // set_pins(LED_4, LED_1); //LED 2C
                               delay(2);
                               set_pins(LED_3, LED_2); //LED 2B
                               delay(2); 
                              // set_pins(LED_2, LED_3); //LED 2A
                               delay(2); 
                               set_pins(LED_2, LED_4); //LED 3C
                               delay(2);
                               set_pins(LED_3, LED_4); //LED 3B
                               delay(2); 
                               set_pins(LED_4, LED_3); //LED 3A
                               delay(2); 
                               
                              
                            }

                            void allon()

                            {

                               set_pins(LED_1, LED_2); //LED 1A
                               delay(2);                
                               set_pins(LED_2, LED_1); //LED 1B
                               delay(2);
                              set_pins(LED_1, LED_4);  //LED 1C
                               delay(2);
                               set_pins(LED_4, LED_1); //LED 2C
                               delay(2);
                               set_pins(LED_3, LED_2); //LED 2B
                               delay(2);
                               set_pins(LED_2, LED_3); //LED 2A
                               delay(2); 
                               set_pins(LED_2, LED_4); //LED 3C
                               delay(2);
                               set_pins(LED_3, LED_4); //LED 3B
                               delay(2);
                               set_pins(LED_4, LED_3); //LED 3A
                               delay(2);

                            }

                            void alloff()

                            {
                             reset_pins();
                             delay(20);
                              
                            }
                


LED Cube Videos


Main Cube Video and one Experiment's Video is down there. In the Experiment, there is Light Design with smoke effect made with the help of 3x3 led cube and Arduino.




Fusion of DHT22 & 3x3 LED CUBE


CODE



                      #include "DHT.h"
                      #define DHTPIN 2   
                      #define LED1 3  
                      #define LED2 4 
                      #define LED3 5
                      #define LED4 6 
                      #define LED5 7 
                      #define LED6 8
                      #define LED7 9 
                      #define LED8 10
                      #define LED9 11
                        
                      #define DHTTYPE DHT22   

                      DHT dht(DHTPIN, DHTTYPE);

                      void setup() {
                        Serial.begin(9600);
                        Serial.println("DHTxx test!");

                        dht.begin();
                       
                         
                          pinMode(A0,INPUT);    //PIN A0 set as output
                          pinMode(A1,INPUT);   // PIN A1 set as output
                          pinMode(A2,INPUT);   // PIN A2 set as output
                          pinMode(LED1,INPUT);
                          pinMode(LED2,INPUT);
                          pinMode(LED3,INPUT);
                          pinMode(LED4,INPUT);
                          pinMode(LED5,INPUT);
                          pinMode(LED6,INPUT);
                          pinMode(LED7,INPUT);
                          pinMode(LED8,INPUT);
                          pinMode(LED9,INPUT);
                          
                            // pull up the A2 pin

                            /* add setup code here, setup code runs once when the processor starts */

                            /* add setup code here, setup code runs once when the processor starts */

                      }

                      void loop() {
                        
                        
                        float h = dht.readHumidity();
                        float t = dht.readTemperature();
                        float f = dht.readTemperature(true);

                        if (isnan(h) || isnan(t) || isnan(f)) {
                          Serial.println("Failed to read from DHT sensor!");
                          return;
                        }

                        float hif = dht.computeHeatIndex(f, h);
                        float hic = dht.computeHeatIndex(t, h, false);

                        Serial.print("Humidity: ");
                        Serial.print(h);
                        Serial.print(" %\t");
                        Serial.print("Temperature: ");
                        Serial.print(t);
                        Serial.print(" *C ");
                        Serial.print(f);
                        Serial.print(" *F\t");
                        Serial.print("Heat index: ");
                        Serial.print(hic);
                        Serial.print(" *C ");
                        Serial.print(hif);
                        Serial.println(" *F");

                        if(t<26)
                        {
                         for(int j=0; j<200; j++)
                      {
                        layer1();
                        delay(0.5);
                        
                      } 
                        }
                        else if(t>=26 && t<27)
                        {
                          for(int j=0;j<200;j++)
                          {
                            layer1();
                            layer2();
                            delay(0.5);
                          }
                        }
                        else 
                        {
                          for(int j=0;j<200;j++)
                          {
                            layer1();
                            layer2();
                            layer3();
                            delay(0.5);
                            
                          }
                        }
                      /* for(int k=0;k<200;k++)
                       { 
                        if(t<=26)
                        {
                         for(int j=0; j<200; j++)
                      {
                        layer1();
                        delay(0.5);
                        
                      } 
                        }

                      else if(t>26 && t<27)

                      {
                            for(int j=0; j<200; j++)
                      {
                        layer1();
                        delay(0.5);
                        layer2();
                        delay(0.5);
                        
                      } 
                      }
                      else
                      {
                          for(int j=0; j<200; j++)
                      {
                       layer1();
                        delay(0.5);
                        layer2();
                        delay(0.5);
                        layer3();
                        delay(0.5);
                        
                      } 
                      }
                        

                       }*/
                      }


                      void set_pins(int high_pin, int low_pin)
                      {
                         reset_pins();
                         pinMode(high_pin, OUTPUT);
                         pinMode(low_pin, OUTPUT);
                         digitalWrite(high_pin, HIGH);
                         digitalWrite(low_pin,LOW);
                      }

                      void reset_pins()
                      {
                         for(int i=3;i<=11;i++)
                         {
                          pinMode(i, INPUT);
                          digitalWrite(i, LOW);
                         }
                       pinMode(A0, INPUT);
                       pinMode(A1, INPUT);
                       pinMode(A2, INPUT);
                       digitalWrite(A0, LOW);
                       digitalWrite(A1, LOW);
                       digitalWrite(A2, LOW);
                      }

                      void layer1()
                      {

                       set_pins(LED1, A0);
                       delay(1);
                       set_pins(LED2, A0);
                       delay(1);
                       set_pins(LED3, A0);
                       delay(1);
                       set_pins(LED4, A0);
                       delay(1);
                       set_pins(LED5, A0);
                       delay(1);
                       set_pins(LED6, A0);
                       delay(1);
                       set_pins(LED7, A0);
                       delay(1);
                       set_pins(LED8, A0);
                       delay(1);
                       set_pins(LED9, A0);
                       delay(1);

                      }

                      void layer2()
                      {
                          
                       set_pins(LED1, A1);
                       delay(1);
                       set_pins(LED2, A1);
                       delay(1);
                       set_pins(LED3, A1);
                       delay(1);
                       set_pins(LED4, A1);
                       delay(1);
                       set_pins(LED5, A1);
                       delay(1);
                       set_pins(LED6, A1);
                       delay(1);
                       set_pins(LED7, A1);
                       delay(1);
                       set_pins(LED8, A1);
                       delay(1);
                       set_pins(LED9, A1);
                       delay(1);

                      }

                      void layer3()
                      {

                       set_pins(LED1, A2);
                       delay(1);
                       set_pins(LED2, A2);
                       delay(1);
                       set_pins(LED3, A2);
                       delay(1);
                       set_pins(LED4, A2);
                       delay(1);
                       set_pins(LED5, A2);
                       delay(1);
                       set_pins(LED6, A2);
                       delay(1);
                       set_pins(LED7, A2);
                       delay(1);
                       set_pins(LED8, A2);
                       delay(1);
                       set_pins(LED9, A2);
                       delay(1);

                      }
                

FUSION Working Videos


On increasing temp, DHT22 will send the varied details to LED cube, by which accordingly it will glow.



THANK YOU! :)