Lab 01 – Sandeep

Description

The lab was about the basic task of blinking an LED. I connected the output pin 13 and the ground pin to the breadboard. Next I placed a resistor (220 ohms) on the breadboard and connected it to the jumper cable connecting output pin 13. The long leg of the LED was connected to the resistor and the shorter was connected to the jumper cable connecting to the ground pin. I wrote a code to vary the duration of LED blinking using a for loop. This reminded me of the lights we have up at diwali (festival of lights) where a similar random repeating set of LEDs are lit.

Components

  • 1 Arduino Uno R3
  • 1 Breadboard
  • 1 LED
  • 5 jumper cables
  • 1 USB power cable

Code

/*
* Lab 01: LED Blink
* Sandeep Pal
* Prof : Kimiko Ryokai
* TA : Noura Howell
*
* Description:
*
* The following code is a modification of the basic example of LED blinking using and Arduino
* I have made the LEDs blink at a varying rate over time by using a for loop
*
* Materials:
*
* 1 Arduino Uno R3
* 1 Breadboard
* 1 LED
* 5 jumper cables
* 1 USB power cable
*
*
*/

/*
* Defining output pin
*/
int ledPin = 13;

/*
* Writing the setup function to initialize the output pin to 13
*/
void setup() {
pinMode( ledPin, OUTPUT);
}

void loop() {
// writing a for loop to vary the duration for which the LED should blink
for(int j =0; j<5;j++){ int jVal = j*200; //writing high voltage to the digital output : 13 digitalWrite(ledPin, HIGH); //modifying the delay based on the loop variable delay(1000-jVal); //writing low voltage to the digital output : 13 digitalWrite(ledPin, LOW); delay(jVal); } }

 

Leave a Reply