Create Arduino Projects

Push Button....

Connect all the components as this circuit.
If you connected these all components, you can open the Arduino IDE Software and write code.

The code is below,

...........................................................//Start of the code//.........................................................


int buttonstate = 2;  //Varialble buttonstate to 2

void setup() {
  pinMode(13,OUTPUT);
  pinMode(2,INPUT);
}

void loop() {
  buttonstate = digitalRead(2);  //Read the digitalpin - 2

  if(buttonstate == HIGH)     //If buttonstate high,
    digitalWrite(13,HIGH);  //Give high voltage to LED

  else                      //else,
    digitalWrite(13,LOW);  //Give low voltage to LED

...........................................................//End of the code//.........................................................


Knight Rider LED Pattern....

CY_5441] Arduino Knight Rider Circuit Schematic Wiring


Connect all the components as this circuit.
If you connected these all components, you can open the Arduino IDE Software and write code.

The code is below,

...........................................................//Start of the code//.........................................................

void setup() {
  pinMode(0,OUTPUT);
  pinMode(1,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);
}

void loop() {

  int t = 80;  //Variable t to 80

  digitalWrite(0,HIGH);
  delay(t);
  digitalWrite(0,LOW);

  digitalWrite(1,HIGH);
  delay(t);
  digitalWrite(1,LOW);

   digitalWrite(2,HIGH);
  delay(t);
  digitalWrite(2,LOW);

   digitalWrite(3,HIGH);
  delay(t);
  digitalWrite(3,LOW);

   digitalWrite(4,HIGH);
  delay(t);
  digitalWrite(4,LOW);

   digitalWrite(5,HIGH);
  delay(t);
  digitalWrite(5,LOW);

  digitalWrite(6,HIGH);
  delay(t);
  digitalWrite(6,LOW);

   digitalWrite(7,HIGH);
  delay(t);
  digitalWrite(7,LOW);

  digitalWrite(8,HIGH);
  delay(t);
  digitalWrite(8,LOW);

  digitalWrite(9,HIGH);
  delay(t);
  digitalWrite(9,LOW);

   digitalWrite(8,HIGH);
  delay(t);
  digitalWrite(8,LOW);

   digitalWrite(7,HIGH);
  delay(t);
  digitalWrite(7,LOW);

   digitalWrite(6,HIGH);
  delay(t);
  digitalWrite(6,LOW);

   digitalWrite(5,HIGH);
  delay(t);
  digitalWrite(5,LOW);

   digitalWrite(4,HIGH);
  delay(t);
  digitalWrite(4,LOW);

  digitalWrite(3,HIGH);
  delay(t);
  digitalWrite(3,LOW);

  digitalWrite(2,HIGH);
  delay(t);
  digitalWrite(2,LOW);

  digitalWrite(1,HIGH);
  delay(t);
  digitalWrite(1,LOW);

}

Post a Comment

0 Comments