Zigster
Published © GPL3+

Flash_BRIGHT_BEGINNER

Two setups for Knight Rider circuit.

BeginnerProtip1,169
Flash_BRIGHT_BEGINNER

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
Resistor 330 ohm
Resistor 330 ohm
Resistors, for this circuit, can actually be 247 ohm upwards. Too high and LEDs get dimmer, though.
×10
Jumper wires (generic)
Jumper wires (generic)
Used to connect your Arduino to the circuit/components.
×11
Solderless Breadboard Full Size
Solderless Breadboard Full Size
In case you build both circuits on one board at the same time.
×1

Story

Read more

Schematics

Comparison Knight Rider circuits

Super-beginner programming.

Code

Flash_Bright_Beginner_code

Arduino
There are two circuits to see and the code shows how everything works.
/* Flash BRIGHT = Larsen scanner/Knight Rider easy-learner coding.
                 By Neil Doherty 09/2019
 First, the Arduino Editor does not load these notes onto a board,
it only loads the operating code.
 Pins are where you push jumper wires into.
*/ 

int LED3 = 3;   // Each Arduino pin has a number or name.
int LED4 = 4;   // Here,a value is assigned to the pins
int LED5 = 5;   // numbered 3 to 12, using int (integer).
int LED6 = 6;   // A jumper-wire connects each Arduino pin
int LED7 = 7;   // to the positive/long leg of an LED
int LED8 = 8;   // (L-ight E-mitting D-iode) on a 'breadboard'.
int LED9 = 9;   // As it's name implies, an actual breadboard
int LED10 = 10; // was first used to tap pins into and wires
int LED11 = 11; // strung between, making connections.
int LED12 = 12;

const int DELAY = 50; // const int uses less memory than int.
                      // For this circuit all of them could use
                      // const int, but it illustrates both uses.
                      // The main difference is that with int, 
                      // you can change the value inside the loop
                      // function which you will come to learn can 
                      // be very useful, whereas const int cannot
                      // be changed.
void setup() {


  pinMode(LED3, OUTPUT); // pinMode is a command to the Arduino
  pinMode(LED4, OUTPUT); // to apply what is in the brackets.
  pinMode(LED5, OUTPUT); // < in this case, (LED5,set to transmit)
  pinMode(LED6, OUTPUT); // And so on for the others.
  pinMode(LED7, OUTPUT); // INPUT only applies to certain pins when
  pinMode(LED8, OUTPUT); // used.
  pinMode(LED9, OUTPUT);
  pinMode(LED10, OUTPUT);
  pinMode(LED11, OUTPUT);
  pinMode(LED12, OUTPUT);


  digitalWrite(12, LOW); // These commands switch all the LEDs
  digitalWrite(11, LOW); // to no power out. LOW meaning OFF
  digitalWrite(10, LOW); // HIGH meaning ON
  digitalWrite(9, LOW);  // These lines make sure ALL LEDs are
  digitalWrite(8, LOW);  // off to begin with.
  digitalWrite(7, LOW);
  digitalWrite(6, LOW);
  digitalWrite(5, LOW);
  digitalWrite(4, LOW);
  digitalWrite(3, LOW);

}

void loop() {
  //Forward
  digitalWrite(12, HIGH); // Switch LED attached to pin 12 on
  delay(DELAY);           // allowing the LED to light up HIGH
  digitalWrite(12, LOW);  // for a period of DELAY = 50
  delay(DELAY);           // microseconds = 50m, where 1000m is 1 second.
  digitalWrite(11, HIGH); // Then it is switched LOW for the next 50m
  delay(DELAY);
  digitalWrite(11, LOW);  // This section lights the LEDs in one direction
  delay(DELAY);
  digitalWrite(10, HIGH); // digitalwrite just says 'let there be light'
  delay(DELAY);           // well, only for the relevant LED, that is.
  digitalWrite(10, LOW);  // It instructs the Arduino to make the power
  delay(DELAY);           // to the pin ON/HIGH or OFF/LOW.
  digitalWrite(9, HIGH);
  delay(DELAY);
  digitalWrite(9, LOW);
  delay(DELAY);
  digitalWrite(8, HIGH);
  delay(DELAY);
  digitalWrite(8, LOW);
  delay(DELAY);
  digitalWrite(7, HIGH);
  delay(DELAY);
  digitalWrite(7, LOW);
  delay(DELAY);
  digitalWrite(6, HIGH);
  delay(DELAY);
  digitalWrite(6, LOW);
  delay(DELAY);
  digitalWrite(5, HIGH);
  delay(DELAY);
  digitalWrite(5, LOW);
  delay(DELAY);
  digitalWrite(4, HIGH);
  delay(DELAY);
  digitalWrite(4, LOW);
  delay(DELAY);
  digitalWrite(3, HIGH);
  delay(DELAY);
  digitalWrite(3, LOW);
  delay(DELAY);

  // NOW Reverse

  digitalWrite(4, LOW);  // This section makes the LEDs light up
  delay(DELAY);          // in the other direction.
  digitalWrite(5, HIGH); 
  delay(DELAY);
  digitalWrite(5, LOW);  // You might notice, and wonder, why this 
  delay(DELAY);          // section has neither 3 nor 12 pins repeated.
  delay(DELAY);          // That is because it would cause the two end
  digitalWrite(6, LOW);  // LEDs to double-flash, which would look strange
  delay(DELAY);          // To be sure, add them in, upload again and
  digitalWrite(7, HIGH); // see it happen.
  delay(DELAY);
  digitalWrite(7, LOW);  // Experiment by changing 
  delay(DELAY);
  digitalWrite(8, HIGH);
  delay(DELAY);
  digitalWrite(8, LOW);
  delay(DELAY);
  digitalWrite(9, HIGH);
  delay(DELAY);
  digitalWrite(9, LOW);
  delay(DELAY);
  digitalWrite(10, HIGH);
  delay(DELAY);
  digitalWrite(10, LOW);
  delay(DELAY);
  digitalWrite(11, HIGH);
  delay(DELAY);
  digitalWrite(11, LOW);
  delay(DELAY);

}

Credits

Zigster
0 projects • 4 followers

Comments