Skip to main content

#LESSON 02-LED CHASER 




CODE
/* LED CHASER
https://electronicassit.blogspot.in/
ARJUN ARANGIL
9444868542 */
    

int i,j;
void setup()
{
  i=25; // blinking time
  j=60; //blinking time
  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);
  pinMode(11, OUTPUT);
  pinMode(12, OUTPUT);
  pinMode(13, OUTPUT); 
}

void loop(){
  

  digitalWrite(4, HIGH);
  delay(i);
  digitalWrite(4, LOW);
  delay(j);
  digitalWrite(4, HIGH);
  delay(i);
  digitalWrite(4, LOW);
  delay(j);
  digitalWrite(8, HIGH);
  delay(i);
  digitalWrite(8, LOW);
  delay(j);
  digitalWrite(8, HIGH);
  delay(i);
  digitalWrite(8, LOW);
  delay(j);
  digitalWrite(2, HIGH);
  delay(i);
  digitalWrite(2, LOW);
  delay(j);
  digitalWrite(2, HIGH);
  delay(i);
  digitalWrite(2, LOW);
  delay(j);
  digitalWrite(10, HIGH);
  delay(i);
  digitalWrite(10, LOW);
  delay(j);
  digitalWrite(10, HIGH);
  delay(i);
  digitalWrite(10, LOW);
  delay(j);
  digitalWrite(3, HIGH);
  delay(i);
  digitalWrite(3, LOW);
  delay(j);
  digitalWrite(3, HIGH);
  delay(i);
  digitalWrite(3, LOW);
  delay(j);
  digitalWrite(13, HIGH);
  delay(i);
  digitalWrite(13, LOW);
  delay(j);
  digitalWrite(13, HIGH);
  delay(i);
  digitalWrite(13, LOW);
  delay(j);
  digitalWrite(7, HIGH);
  delay(i);
  digitalWrite(7, LOW);
  delay(j);
  digitalWrite(7, HIGH);
  delay(i);
  digitalWrite(7, LOW);
  delay(j);
  digitalWrite(12, HIGH);
  delay(i);
  digitalWrite(12, LOW);
  delay(j);
  digitalWrite(12, HIGH);
  delay(i);
  digitalWrite(12, LOW);
  delay(j);
  digitalWrite(5, HIGH);
  delay(i);
  digitalWrite(5, LOW);
  delay(j);
  digitalWrite(5, HIGH);
  delay(i);
  digitalWrite(5, LOW);
  delay(j);
  digitalWrite(11, HIGH);
  delay(i);
  digitalWrite(11, LOW);
  delay(j);
  digitalWrite(11, HIGH);
  delay(i);
  digitalWrite(11, LOW);
  delay(j);
  digitalWrite(6, HIGH);
  delay(i);
  digitalWrite(6, LOW);
  delay(j);
  digitalWrite(6, HIGH);
  delay(i);
  digitalWrite(6, LOW);
  delay(j);
  digitalWrite(9, HIGH);
  delay(i);
  digitalWrite(9, LOW);
  delay(j);
  digitalWrite(9, HIGH);
  delay(i);
  digitalWrite(9, LOW);
  delay(j);
  
  digitalWrite(13, HIGH);
  delay(i);
  digitalWrite(13, LOW);
  delay(j);
  digitalWrite(12, HIGH);
  delay(i);
  digitalWrite(12, LOW);
  delay(j);
  digitalWrite(11, HIGH);
  delay(i);
  digitalWrite(11, LOW);
  delay(j);
  digitalWrite(10, HIGH);
  delay(i);
  digitalWrite(10, LOW);
  delay(j);
  digitalWrite(9, HIGH);
  delay(i);
  digitalWrite(9, LOW);
  delay(j);
  digitalWrite(8, HIGH);
  delay(i);
  digitalWrite(8, LOW);
  delay(j);
  digitalWrite(7, HIGH);
  delay(i);
  digitalWrite(7, LOW);
  delay(j);
  digitalWrite(6, HIGH);
  delay(i);
  digitalWrite(6, LOW);
  delay(j);
  digitalWrite(5, HIGH);
  delay(i);
  digitalWrite(5, LOW);
  delay(j);
  digitalWrite(4, HIGH);
  delay(i);
  digitalWrite(4, LOW);
  delay(j);
  digitalWrite(3, HIGH);
  delay(i);
  digitalWrite(3, LOW);
  delay(j);
  digitalWrite(2, HIGH);
  delay(i);
  digitalWrite(2, LOW);
  delay(j);
  
  digitalWrite(2, HIGH);
  delay(i);
  digitalWrite(3, HIGH);
  delay(j);
  digitalWrite(4, HIGH);
  delay(i);
  digitalWrite(5, HIGH);
  delay(j);
  digitalWrite(6, HIGH);
  delay(i);
  digitalWrite(7, HIGH);
  delay(j);
  digitalWrite(8, HIGH);
  delay(i);
  digitalWrite(9, HIGH);
  delay(j);
  digitalWrite(10, HIGH);
  delay(i);
  digitalWrite(11, HIGH);
  delay(j);
  digitalWrite(12, HIGH);
  delay(i);
  digitalWrite(13, HIGH);
  delay(j);
  
  digitalWrite(2,LOW);
  delay(i);
  digitalWrite(3,LOW);
  delay(j);
  digitalWrite(4,LOW);
  delay(i);
  digitalWrite(5,LOW);
  delay(j);
  digitalWrite(6,LOW);
  delay(i);
  digitalWrite(7,LOW);
  delay(j);
  digitalWrite(8,LOW);
  delay(i);
  digitalWrite(9,LOW);
  delay(j);
  digitalWrite(10,LOW);
  delay(i);
  digitalWrite(11,LOW);
  delay(j);
  digitalWrite(12,LOW);
  delay(i);
  digitalWrite(13,LOW);
  delay(j);
  
  digitalWrite(13,HIGH);
  delay(i);
  digitalWrite(2,HIGH);
  delay(j);
  digitalWrite(12,HIGH);
  delay(i);
  digitalWrite(3,HIGH);
  delay(j);
  digitalWrite(11,HIGH);
  delay(i);
  digitalWrite(4,HIGH);
  delay(j);
  digitalWrite(10,HIGH);
  delay(i);
  digitalWrite(5,HIGH);
  delay(j);
  digitalWrite(9,HIGH);
  delay(i);
  digitalWrite(6,HIGH);
  delay(j);
  digitalWrite(8,HIGH);
  delay(i);
  digitalWrite(7,HIGH);
  delay(j);
  
  digitalWrite(2, HIGH);
  delay(i);
  digitalWrite(2, LOW);
  delay(j);
  digitalWrite(3, HIGH);
  delay(i);
  digitalWrite(3, LOW);
  delay(j);
  digitalWrite(4, HIGH);
  delay(i);
  digitalWrite(4, LOW);
  delay(j);
  digitalWrite(5, HIGH);
  delay(i);
  digitalWrite(5, LOW);
  delay(j);
  digitalWrite(6, HIGH);
  delay(i);
  digitalWrite(6, LOW);
  delay(j);
  digitalWrite(7, HIGH);
  delay(i);
  digitalWrite(7, LOW);
  delay(j);
  digitalWrite(8, HIGH);
  delay(i);
  digitalWrite(8, LOW);
  delay(j);
  digitalWrite(9, HIGH);
  delay(i);
  digitalWrite(9, LOW);
  delay(j);
  digitalWrite(10, HIGH);
  delay(i);
  digitalWrite(10, LOW);
  delay(j);
  digitalWrite(11, HIGH);
  delay(i);
  digitalWrite(11, LOW);
  delay(j);
  digitalWrite(12, HIGH);
  delay(i);
  digitalWrite(12, LOW);
  delay(j);
  digitalWrite(13, HIGH);
  delay(i);
  digitalWrite(13, LOW);
  delay(j);
  
  digitalWrite(2, HIGH);
  delay(i);
  digitalWrite(3, HIGH);
  delay(j);
  digitalWrite(4, HIGH);
  delay(i);
  digitalWrite(5, HIGH);
  delay(j);
  digitalWrite(6, HIGH);
  delay(i);
  digitalWrite(7, HIGH);
  delay(j);
  digitalWrite(8, HIGH);
  delay(i);
  digitalWrite(9, HIGH);
  delay(j);
  digitalWrite(10, HIGH);
  delay(i);
  digitalWrite(11, HIGH);
  delay(j);
  digitalWrite(12, HIGH);
  delay(i);
  digitalWrite(13, HIGH);
  delay(j);
  
  digitalWrite(13,LOW);
  delay(i);
  digitalWrite(12,LOW);
  delay(j);
  digitalWrite(11,LOW);
  delay(i);
  digitalWrite(10,LOW);
  delay(j);
  digitalWrite(9,LOW);
  delay(i);
  digitalWrite(8,LOW);
  delay(j);
  digitalWrite(7,LOW);
  delay(i);
  digitalWrite(6,LOW);
  delay(j);
  digitalWrite(5,LOW);
  delay(i);
  digitalWrite(4,LOW);
  delay(j);
  digitalWrite(3,LOW);
  delay(i);
  digitalWrite(2,LOW);
  delay(j);
  
  digitalWrite(2, HIGH);
  delay(i);
  digitalWrite(2, LOW);
  delay(j);
  digitalWrite(3, HIGH);
  delay(i);
  digitalWrite(3, LOW);
  delay(j);
  digitalWrite(4, HIGH);
  delay(i);
  digitalWrite(4, LOW);
  delay(j);
  digitalWrite(5, HIGH);
  delay(i);
  digitalWrite(5, LOW);
  delay(j);
  digitalWrite(6, HIGH);
  delay(i);
  digitalWrite(6, LOW);
  delay(j);
  digitalWrite(7, HIGH);
  delay(i);
  digitalWrite(7, LOW);
  delay(j);
  digitalWrite(8, HIGH);
  delay(i);
  digitalWrite(8, LOW);
  delay(j);
  digitalWrite(9, HIGH);
  delay(i);
  digitalWrite(9, LOW);
  delay(j);
  digitalWrite(10, HIGH);
  delay(i);
  digitalWrite(10, LOW);
  delay(j);
  digitalWrite(11, HIGH);
  delay(i);
  digitalWrite(11, LOW);
  delay(j);
  digitalWrite(12, HIGH);
  delay(i);
  digitalWrite(12, LOW);
  delay(j);
  digitalWrite(13, HIGH);
  delay(i);
  digitalWrite(13, LOW);
  delay(j);
  
  digitalWrite(13, HIGH);
  delay(i);
  digitalWrite(12, HIGH);
 delay(j);
  digitalWrite(11, HIGH);
  delay(i);
  digitalWrite(10, HIGH);
  delay(j);
  digitalWrite(9, HIGH);
  delay(i);
  digitalWrite(8, HIGH);
  delay(j);
  digitalWrite(7, HIGH);
  delay(i);
  digitalWrite(6, HIGH);
  delay(j);
  digitalWrite(5, HIGH);
  delay(i);
  digitalWrite(4, HIGH);
 delay(j);
  digitalWrite(3, HIGH);
  delay(i);
  digitalWrite(2, HIGH);
 delay(j);
  
  digitalWrite(13,LOW);
  delay(i);
  digitalWrite(2,LOW);
 delay(j);
  digitalWrite(12,LOW);
  delay(i);
  digitalWrite(3,LOW);
  delay(j);
  digitalWrite(11,LOW);
  delay(i);
  digitalWrite(4,LOW);
  delay(j);
  digitalWrite(10,LOW);
  delay(i);
  digitalWrite(5,LOW);
delay(j);
  digitalWrite(9,LOW);
  delay(i);
  digitalWrite(6,LOW);
  delay(j);
  digitalWrite(8,LOW);
  delay(i);
  digitalWrite(7,LOW);
  delay(j);
  
  digitalWrite(13, HIGH);
  delay(i);
  digitalWrite(12, HIGH);
  delay(j);
  digitalWrite(11, HIGH);
  delay(i);
  
  digitalWrite(11,LOW);
delay(j);
  digitalWrite(12,LOW);
  delay(i);
  digitalWrite(13,LOW);
 delay(j);
  
  digitalWrite(10, HIGH);
  delay(i);
  digitalWrite(9, HIGH);
  delay(j);
  digitalWrite(8, HIGH);
  delay(i);
  
  digitalWrite(8,LOW);
  delay(j);
  digitalWrite(9,LOW);
  delay(i);
  digitalWrite(10,LOW);
 delay(j);
  
  digitalWrite(7, HIGH);
  delay(i);
  digitalWrite(6, HIGH);
  delay(j);
  digitalWrite(5, HIGH);
  delay(i);
  
  digitalWrite(5,LOW);
delay(j);
  digitalWrite(6,LOW);
  delay(i);
  digitalWrite(7,LOW);
 delay(j);
  
  digitalWrite(4, HIGH);
  delay(i);
  digitalWrite(3, HIGH);
 delay(j);
  digitalWrite(2, HIGH);
  delay(i);
  
  digitalWrite(2,LOW);
  delay(j);
  digitalWrite(3,LOW);
  delay(i);
  digitalWrite(4,LOW);
delay(j);
  
  digitalWrite(13, HIGH);
  delay(i);
  digitalWrite(13, LOW);
  delay(j);
  digitalWrite(13, HIGH);
  delay(i);
  digitalWrite(13, LOW);
delay(j);
  digitalWrite(12, HIGH);
  delay(i);
  digitalWrite(12, LOW);
  delay(j);
  digitalWrite(12, HIGH);
  delay(i);
  digitalWrite(12, LOW);
  delay(j);
  digitalWrite(11, HIGH);
  delay(i);
  digitalWrite(11, LOW);
  delay(j);
  digitalWrite(11, HIGH);
  delay(i);
  digitalWrite(11, LOW);
delay(j);
  digitalWrite(10, HIGH);
  delay(i);
  digitalWrite(10, LOW);
delay(j);
  digitalWrite(10, HIGH);
  delay(i);
  digitalWrite(10, LOW);
 delay(j);
  digitalWrite(9, HIGH);
  delay(i);
  digitalWrite(9, LOW);
  delay(j);
  digitalWrite(9, HIGH);
  delay(i);
  digitalWrite(9, LOW);
delay(j);
  digitalWrite(8, HIGH);
  delay(i);
  digitalWrite(8, LOW);
  delay(j);
  digitalWrite(8, HIGH);
  delay(i);
  digitalWrite(8, LOW);
  delay(j);
  digitalWrite(7, HIGH);
  delay(i);
  digitalWrite(7, LOW);
  delay(j);
  digitalWrite(7, HIGH);
  delay(i);
  digitalWrite(7, LOW);
  delay(j);
  digitalWrite(6, HIGH);
  delay(i);
  digitalWrite(6, LOW);
  delay(j);
  digitalWrite(6, HIGH);
  delay(i);
  digitalWrite(6, LOW);
 delay(j);
  digitalWrite(5, HIGH);
  delay(i);
  digitalWrite(5, LOW);
 delay(j);
  digitalWrite(5, HIGH);
  delay(i);
  digitalWrite(5, LOW);
 delay(j);
  digitalWrite(4, HIGH);
  delay(i);
  digitalWrite(4, LOW);
  delay(j);
  digitalWrite(4, HIGH);
  delay(i);
  digitalWrite(4, LOW);
  delay(j);
  digitalWrite(3, HIGH);
  delay(i);
  digitalWrite(3, LOW);
  delay(j);
  digitalWrite(3, HIGH);
  delay(i);
  digitalWrite(3, LOW);
 delay(j);
  digitalWrite(2, HIGH);
  delay(i);
  digitalWrite(2, LOW);
 delay(j);
  digitalWrite(2, HIGH);
  delay(i);
  digitalWrite(2, LOW);
  delay(j);
  
  digitalWrite(2, HIGH);
  delay(i);
  digitalWrite(3, HIGH);
 delay(j);
  digitalWrite(4, HIGH);
  delay(i);
  digitalWrite(5, HIGH);
  delay(j);
  digitalWrite(6, HIGH);
  delay(i);
  digitalWrite(7, HIGH);
  delay(j);
  digitalWrite(8, HIGH);
  delay(i);
  digitalWrite(9, HIGH);
  delay(j);
  digitalWrite(10, HIGH);
  delay(i);
  digitalWrite(11, HIGH);
  delay(j);
  digitalWrite(12, HIGH);
  delay(i);
  digitalWrite(13, HIGH);
delay(j);
  
  digitalWrite(2, LOW);
  delay(i);
  digitalWrite(2, HIGH);
  delay(j);
  digitalWrite(3, LOW);
  delay(i);
  digitalWrite(3, HIGH);
  delay(j);
  digitalWrite(4, LOW);
  delay(i);
  digitalWrite(4, HIGH);
  delay(j);
  digitalWrite(5, LOW);
  delay(i);
  digitalWrite(5, HIGH);
  delay(j);
  digitalWrite(6, LOW);
  delay(i);
  digitalWrite(6, HIGH);
  delay(j);
  digitalWrite(7, LOW);
  delay(i);
  digitalWrite(7, HIGH);
  delay(j);
  digitalWrite(8, LOW);
  delay(i);
  digitalWrite(8, HIGH);
delay(j);
  digitalWrite(9, LOW);
  delay(i);
  digitalWrite(9, HIGH);
  delay(j);
  digitalWrite(10, LOW);
  delay(i);
  digitalWrite(10, HIGH);
  delay(j);
  digitalWrite(11, LOW);
  delay(i);
  digitalWrite(11, HIGH);
  delay(j);
  digitalWrite(12, LOW);
  delay(i);
  digitalWrite(12, HIGH);
  delay(j);
  digitalWrite(13, LOW);
  delay(i);
  digitalWrite(13, HIGH);
  delay(j);
  
  digitalWrite(13,LOW);
  delay(i);
  digitalWrite(12,LOW);
  delay(j);
  digitalWrite(11,LOW);
  delay(i);
  digitalWrite(10,LOW);
  delay(j);
  digitalWrite(9,LOW);
  delay(i);
  digitalWrite(8,LOW);
  delay(j);
  digitalWrite(7,LOW);
  delay(i);
  digitalWrite(6,LOW);
  delay(j);
  digitalWrite(5,LOW);
  delay(i);
  digitalWrite(4,LOW);
  delay(j);
  digitalWrite(3,LOW);
  delay(i);
  digitalWrite(2,LOW);
delay(j);
}

Comments

  1. thank you berry much for the help , learning and code

    ReplyDelete
  2. I`m try to understen the pic 16f84A , 16F628 for led chaser diagram and code with 12 leds.if you work with that in a future video please let me know

    ReplyDelete

Post a Comment

Popular posts from this blog

Ultrasonic sensor using Arduino Code /*     CAR PARKING SENSOR    https://electronicassit.blogspot.in    ARJUN ARANGIL    9444868542 */ // Define pins for ultrasonic and buzzer int const trigPin = 5; int const echoPin = 6; int const buzzPin = 12; void setup() { pinMode(trigPin, OUTPUT); // trig pin will have pulses output pinMode(echoPin, INPUT); // echo pin should be input to get pulse width pinMode(buzzPin, OUTPUT); // buzz pin is output to control buzzering } void loop() { // Duration will be the input pulse width and distance will be the distance to the obstacle in centimeters int duration, distance; // Output pulse with 1ms width on trigPin digitalWrite(trigPin, HIGH); delay(1); digitalWrite(trigPin, LOW); // Measure the pulse input in echo pin duration = pulseIn(echoPin, HIGH); // Distance is half the duration devided by 29.1 (from data...
#Lesson 01- Blinking LED                 The simplest thing you can do with a Arduino to blinks the LED Hardware Required   -   Arduino Board   -  LED   -  220 Ω Resistor   -  Jumper wire   -  Bread board Circuit       The LED is connected to Arduino digital pins and 220Ω resistor is connected series in between Arduino and LED. The resistor which limits the flow of currents.      Connect one end of the resistor to the digital pin correspondent to the LED. Connect the long leg of the LED (+ve leg called as anode) to the other end of the resistor and connect the short leg of the LED (-ve leg called as cathode) to the Gnd Code After you build the circuit plug the Arduino into your computer, start the Arduino software(IDE) and enter the code given below /*   Blink   https://electronicassit.blogspot.in/   9444868542 *...
PIR Senesor / Motion Sensor using Arduino  Code /* PIR SENSOR / MOTION SENSOR https://electronicassist.blogspot.in/ ARJUN ARANGIL 9444868542 */ int ledPin   = 13;                 // choose the pin for the LED int inputPin = 2;                  // choose the input pin (for PIR sensor) int leda     = 12;                 // choose the pin for the LED int ledb     = 11;                 // choose the pin for the LED int pirState = LOW;                // we start, assuming no motion detected int val      = 0;                  // variable for reading the pin status void setup()  {   pinMode(ledPin, OUTPUT);        ...