Arduino Snowflake

  • Class: Technology.
  • Software: Arduino.
  • Material/details: Cardboard, Male/male jumper wires, Breadboard, Arduino Uno, Blue LEDs x6, Resistors (1 k ohm) x6, Photoresistor, Resistor (10 k ohm).
  • Aim: Explore Arduino and learn how to program in Arduino Language.
 
  • Process:

For this task, I decided to make simple snowflake which consists of 6 Blue LEDs. The idea is that LEDs turn on when lights in the room are turned off. In order to make it, I was needed to solder LEDs to the jumper wires and connect everything via breadboard to the Arduino (cathode to the ground and anode to the pins). I was not able to show it in the scheme, but for LEDs I used 1 k ohm resistors and for the Photoresistor 10 k ohm resistor.

   

I was needed to make a code which will work for the snowflake. At the start, I listed all components (six LEDs and one photoresistor). Then, in “void setup” I listed what is going to be input and what is an output. In the “void loop” I create the algorithm for a lighted and non-lighted environment. “int ldrStatus” reads the values of Photoresistor. In my case I used ldrStatus <=300, however, this number can be changed.

  • Code for snowflake:

const int ledPin1 = 8;

const int ledPin2 = 9;

const int ledPin3 = 10;

const int ledPin4 = 11;

const int ledPin5 = 12;

const int ledPin6 = 13;

const int ldrPin = A0;

 void setup() {

  pinMode(ledPin1, OUTPUT);

  pinMode(ledPin2, OUTPUT);

  pinMode(ledPin3, OUTPUT);

  pinMode(ledPin4, OUTPUT);

  pinMode(ledPin5, OUTPUT);

  pinMode(ledPin6, OUTPUT);

  pinMode(ldrPin, INPUT);

}

void loop() {

  int ldrStatus = analogRead(ldrPin);

   if (ldrStatus <=300) {

    digitalWrite(ledPin1, HIGH);

    digitalWrite(ledPin2, HIGH);

    digitalWrite(ledPin3, HIGH);

    digitalWrite(ledPin4, HIGH);

    digitalWrite(ledPin5, HIGH);

    digitalWrite(ledPin6, HIGH);

    Serial.println(“LDR is DARK, LED is ON”);

   }

  else {

    digitalWrite(ledPin1, LOW);

    digitalWrite(ledPin2, LOW);

    digitalWrite(ledPin3, LOW);

    digitalWrite(ledPin4, LOW);

    digitalWrite(ledPin5, LOW);

    digitalWrite(ledPin6, LOW);

    Serial.println(“—————“);

  }

}

  •   Result:

Tags:

address: 20 Myasnitskaya ulitsa
(metro stations ‘Lubyanka’ and ‘Kitay-Gorod’)
Moscow 101000 Russia

phone: +7(495)772-95-90 *15026

email: city@hse.ru