Wednesday, 28 June 2017

light effect codes based on the previous light effect project





//try this arduino code
void setup()
{
  pinMode(2, OUTPUT);
  pinMode(3, OUTPUT);
  pinMode(4, OUTPUT);
  pinMode(5, OUTPUT);
  pinMode(6, OUTPUT);
  pinMode(7, OUTPUT);
  pinMode(8, OUTPUT);
  pinMode(9, OUTPUT);
  pinMode(10, OUTPUT);
}
void ring()
{
  digitalWrite(6,HIGH);
  digitalWrite(10,HIGH);
  digitalWrite(4,HIGH);
  digitalWrite(2,HIGH);
  digitalWrite(8,HIGH);
  delay(200);

  digitalWrite(10,LOW);
  digitalWrite(4,LOW);
  digitalWrite(2,LOW);
  digitalWrite(8,LOW);
  delay(200);
 
  digitalWrite(6,HIGH);
  digitalWrite(5,HIGH);
  digitalWrite(3,HIGH);
  digitalWrite(7,HIGH);
  digitalWrite(9,HIGH);
  delay(200);

  digitalWrite(5,LOW);
  digitalWrite(3,LOW);
  digitalWrite(7,LOW);
  digitalWrite(9,LOW);
  delay(200);

  digitalWrite(6,LOW);
 
}
void arr()
{
  digitalWrite(2, HIGH);
  delay(200);
  digitalWrite(3, HIGH);
  delay(200);
  digitalWrite(4, HIGH);
  delay(200);
  digitalWrite(5, HIGH);
  delay(200);
  digitalWrite(6, HIGH);
  delay(200);
  digitalWrite(7, HIGH);
  delay(200);
  digitalWrite(8, HIGH);
  delay(200);
  digitalWrite(9, HIGH);
  delay(200);
  digitalWrite(10, HIGH);
  delay(200);
  digitalWrite(10, LOW);
  delay(200);
  digitalWrite(9, LOW);
  delay(200);
  digitalWrite(8, LOW);
  delay(200);
  digitalWrite(7, LOW);
  delay(200);
  digitalWrite(6, LOW);
  delay(200);
  digitalWrite(5, LOW);
  delay(200);
  digitalWrite(4, LOW);
  delay(200);
  digitalWrite(3, LOW);
  delay(200);
  digitalWrite(2, LOW);
  delay(200);
}
void rot()
{
  digitalWrite(6, HIGH);
  delay(250);
  digitalWrite(8, HIGH);
  delay(200);
  digitalWrite(8, LOW);
  delay(150);
 
  digitalWrite(7, HIGH);
  delay(200);
  digitalWrite(7, LOW);
  delay(150);

  digitalWrite(2, HIGH);
  delay(200);
  digitalWrite(2, LOW);
  delay(150);
 
  digitalWrite(3, HIGH);
  delay(200);
  digitalWrite(3, LOW);
  delay(150);

  digitalWrite(4, HIGH);
  delay(200);
  digitalWrite(4, LOW);
  delay(150);

  digitalWrite(5, HIGH);
  delay(200);
  digitalWrite(5, LOW);
  delay(150);

  digitalWrite(10, HIGH);
  delay(300);
  digitalWrite(10, LOW);
  delay(150);

  digitalWrite(9, HIGH);
  delay(300);
  digitalWrite(9, LOW);
  delay(150);

  digitalWrite(5,LOW);
 
}

void race()
{
 
  digitalWrite(8, HIGH);
  digitalWrite(7, HIGH);
  digitalWrite(2, HIGH);
  delay(300);
  digitalWrite(9, HIGH);
  digitalWrite(6, HIGH);
  digitalWrite(3, HIGH);
  delay(300);
  digitalWrite(10, HIGH);
  digitalWrite(5, HIGH);
  digitalWrite(4, HIGH);
  delay(300);
  digitalWrite(8, LOW);
  digitalWrite(7, LOW);
  digitalWrite(2, LOW);
  delay(300);
  digitalWrite(9, LOW);
  digitalWrite(6, LOW);
  digitalWrite(3, LOW);
  delay(300);
  digitalWrite(10, LOW);
  digitalWrite(5, LOW);
  digitalWrite(4, LOW);
  delay(300);
}
void dia()
{
  digitalWrite(4,HIGH);
  delay(90);
  digitalWrite(5,HIGH);
  digitalWrite(3,HIGH);
  delay(90);
  digitalWrite(10,HIGH);
  digitalWrite(6,HIGH);
  digitalWrite(2,HIGH);
  delay(90);
  digitalWrite(9,HIGH);
  digitalWrite(7,HIGH);
  delay(90);
  digitalWrite(8,HIGH);
  delay(150);
 
  digitalWrite(4,LOW);
  delay(90);
  digitalWrite(5,LOW);
  digitalWrite(3,LOW);
  delay(90);
  digitalWrite(10,LOW);
  digitalWrite(6,LOW);
  digitalWrite(2,LOW);
  delay(90);
  digitalWrite(9,LOW);
  digitalWrite(7,LOW);
  delay(90);
  digitalWrite(8,LOW);
  delay(150);
 
 
 
 
}
void loop()
{
  ring();
  ring();
  ring();
  arr();
  arr();
  arr();
  rot();
  rot();
  rot();
  race();
  race();
  race();
  dia();
  dia();
  dia();
  delay(500);
}

Light effects on a light bulb with Arduino

This post is about DIY light effect with Arduino



This is the DIY project we are gonna make
COMPONENTS
  • Arduino and Parts for Arduino
  • 9 light bulbs with low power consumption(i used low power LED)
  • some wires
the circuit is not complex, just the parallel connection,


the circuit will be much easy if we use a diode,
I will upload another post on that.







  • Connect the pins as shown in the circuit diagram 
  • use an external power supply for Arduino (since the USB is not enough for 9 bulbs)


//this is the Arduino code 
//the code is simple and it is easy to understand

void setup()// the setup function runs once when you press reset or power the board
{
   // initialize digital pins as an output.
  pinMode(2, OUTPUT);
  pinMode(3, OUTPUT);
  pinMode(4, OUTPUT);
  pinMode(5, OUTPUT);
  pinMode(6, OUTPUT);
  pinMode(7, OUTPUT);
  pinMode(8, OUTPUT);
  pinMode(9, OUTPUT);
  pinMode(10, OUTPUT);
}
void one()//since the code is huge seperate functions are used which is later called in loop function
{
  digitalWrite(4,HIGH);
  delay(90);
  digitalWrite(5,HIGH);
  digitalWrite(3,HIGH);
  delay(90);
  digitalWrite(10,HIGH);
  digitalWrite(6,HIGH);
  digitalWrite(2,HIGH);
  delay(90);
  digitalWrite(9,HIGH);
  digitalWrite(7,HIGH);
  delay(90);
  digitalWrite(8,HIGH);
  delay(150);
  
  digitalWrite(4,LOW);
  delay(90);
  digitalWrite(5,LOW);
  digitalWrite(3,LOW);
  delay(90);
  digitalWrite(10,LOW);
  digitalWrite(6,LOW);
  digitalWrite(2,LOW);
  delay(90);
  digitalWrite(9,LOW);
  digitalWrite(7,LOW);
  delay(90);
  digitalWrite(8,LOW);
  delay(150);
}
void six()//since the code is huge seperate functions are used which is later called in loop function
{
  digitalWrite(8, HIGH);
  digitalWrite(7, HIGH);
  digitalWrite(2, HIGH);
  delay(90);
  digitalWrite(9, HIGH);
  digitalWrite(6, HIGH);
  digitalWrite(3, HIGH);
  delay(90);
  digitalWrite(10, HIGH);
  digitalWrite(5, HIGH);
  digitalWrite(4, HIGH);
  delay(90);
  digitalWrite(8, LOW);
  digitalWrite(7, LOW);
  digitalWrite(2, LOW);
  delay(90);
  digitalWrite(9, LOW);
  digitalWrite(6, LOW);
  digitalWrite(3, LOW);
  delay(90);
  digitalWrite(10, LOW);
  digitalWrite(5, LOW);
  digitalWrite(4, LOW);
  delay(150);
}
void two()
{
  digitalWrite(10, HIGH);
  digitalWrite(5, HIGH);
  digitalWrite(4, HIGH);
  delay(90);
  digitalWrite(9, HIGH);
  digitalWrite(6, HIGH);
  digitalWrite(3, HIGH);
  delay(90);
  digitalWrite(8, HIGH);
  digitalWrite(7, HIGH);
  digitalWrite(2, HIGH);
  delay(90);
  digitalWrite(10, LOW);
  digitalWrite(5, LOW);
  digitalWrite(4, LOW);
  delay(90);
  digitalWrite(9, LOW);
  digitalWrite(6, LOW);
  digitalWrite(3, LOW);
  delay(90);
  digitalWrite(8, LOW);
  digitalWrite(7, LOW);
  digitalWrite(2, LOW);
  delay(150);
}
void three()//since the code is huge seperate functions are used which is later called in loop function
{
  digitalWrite(10,HIGH);
  delay(90);
  digitalWrite(5,HIGH);
  digitalWrite(9,HIGH);
  delay(90);
  digitalWrite(4,HIGH);
  digitalWrite(6,HIGH);
  digitalWrite(8,HIGH);
  delay(90);
  digitalWrite(3,HIGH);
  digitalWrite(7,HIGH);
  delay(90);
  digitalWrite(2,HIGH);
  delay(150);
  
  digitalWrite(10,LOW);
  delay(90);
  digitalWrite(5,LOW);
  digitalWrite(9,LOW);
  delay(90);
  digitalWrite(4,LOW);
  digitalWrite(6,LOW);
  digitalWrite(8,LOW);
  delay(90);
  digitalWrite(3,LOW);
  digitalWrite(7,LOW);
  delay(90);
  digitalWrite(2,LOW);
  delay(150);
}
void four()//since the code is huge seperate functions are used which is later called in loop function
{
  digitalWrite(10, HIGH);
  digitalWrite(9, HIGH);
  digitalWrite(8, HIGH);
  delay(90);
  digitalWrite(5, HIGH);
  digitalWrite(6, HIGH);
  digitalWrite(7, HIGH);
  delay(90);
  digitalWrite(4, HIGH);
  digitalWrite(3, HIGH);
  digitalWrite(2, HIGH);
  delay(90);
  digitalWrite(10, LOW);
  digitalWrite(9, LOW);
  digitalWrite(8, LOW);
  delay(90);
  digitalWrite(5, LOW);
  digitalWrite(6, LOW);
  digitalWrite(7, LOW);
  delay(90);
  digitalWrite(4, LOW);
  digitalWrite(3, LOW);
  digitalWrite(2, LOW);
  delay(150);
}
void five()//since the code is huge seperate functions are used which is later called in loop function
{
  digitalWrite(8,HIGH);
  delay(90);
  digitalWrite(7,HIGH);
  digitalWrite(9,HIGH);
  delay(90);
  digitalWrite(10,HIGH);
  digitalWrite(6,HIGH);
  digitalWrite(2,HIGH);
  delay(90);
  digitalWrite(3,HIGH);
  digitalWrite(5,HIGH);
  delay(90);
  digitalWrite(4,HIGH);
  delay(150);
   
  digitalWrite(8,LOW);
  delay(90);
  digitalWrite(7,LOW);
  digitalWrite(9,LOW);
  delay(90);
  digitalWrite(10,LOW);
  digitalWrite(6,LOW);
  digitalWrite(2,LOW);
  delay(90);
  digitalWrite(3,LOW);
  digitalWrite(5,LOW);
  delay(90);
  digitalWrite(4,LOW);
  delay(150);
}
void seven()//since the code is huge seperate functions are used which is later called in loop function
{
  digitalWrite(2,HIGH);
  delay(90);
  digitalWrite(7,HIGH);
  digitalWrite(3,HIGH);
  delay(90);
  digitalWrite(8,HIGH);
  digitalWrite(6,HIGH);
  digitalWrite(4,HIGH);
  delay(90);
  digitalWrite(9,HIGH);
  digitalWrite(5,HIGH);
  delay(90);
  digitalWrite(10,HIGH);
  delay(150);
  
  digitalWrite(2,LOW);
  delay(90);
  digitalWrite(7,LOW);
  digitalWrite(3,LOW);
  delay(90);
  digitalWrite(4,LOW);
  digitalWrite(6,LOW);
  digitalWrite(8,LOW);
  delay(90);
  digitalWrite(9,LOW);
  digitalWrite(5,LOW);
  delay(90);
  digitalWrite(10,LOW);
  delay(150);
}
void eight()//since the code is huge seperate functions are used which is later called in loop function
{
  digitalWrite(4,HIGH);
  digitalWrite(3, HIGH);
  digitalWrite(2, HIGH);
  delay(90);
  digitalWrite(5, HIGH);
  digitalWrite(6, HIGH);
  digitalWrite(7, HIGH);
  delay(90);
  digitalWrite(8, HIGH);
  digitalWrite(9, HIGH);
  digitalWrite(10, HIGH);
  delay(90);
  digitalWrite(4, LOW);
  digitalWrite(3, LOW);
  digitalWrite(2, LOW);
  delay(90);
  digitalWrite(5, LOW);
  digitalWrite(6, LOW);
  digitalWrite(7, LOW);
  delay(90);
  digitalWrite(8, LOW);
  digitalWrite(9, LOW);
  digitalWrite(10, LOW);
  delay(150);
}



void loop()// the loop function runs over and over again forever
{
  one();//functions are called here
  two();
  three();
  four();
  five();
  six();
  seven();
  eight();
  
}
//enjoy the light effects 
//i will upload several other Arduino codes i have written for light effects.





Tuesday, 27 June 2017

Arduino

Let's start with Arduino


    COMPONENTS NEEDED

  • Any Arduino board
  • Arduino IDE software
  • USB connector for your Arduino
This is a very simple project, this project is for beginners in electronic circuits and programming

Arduino is a simple to use microcontroller board, it is easy to use and do not need much experience in programming.

let's start with a simple example 

  • buy any Arduino based boards (i recommend you to buy Arduino Uno which is very cheap and you can replace the microcontroller if anything goes wrong)
  • download Arduino IDE software from Arduino official website (make sure that Java is installed on your computer)
  • plugin you Arduino board to your computer via USB

tools>Board> and select your board type (in my case it is Arduino Uno)


the COM port will be selected by the computer if not select it.


  • Arduino board will have a LED attached to its PIN 13, we will use that LED for this project
  • The code is already available in the examples.



if you open that it will be like this.



then just upload the program to you Arduino


after uploading you will the LED blinking for 1sec


The program has two parts first is the setup and the second is the loop, setup is where you program you gpio pins in an Arduino as input or as an output, and the loop part repeats itself .



Own IOT website and Hardware Using Node MCU (cyber thinks)

NODE MCU code -- website link  Cyberthinks google drive link  cyberthinks website files #include <ESP8266WiFi.h> #include <ArduinoJ...