Week 2 Lvl3 2019

Today we started messing with the Arduino Uno. We learned about how the LED circuits works and how one would code and LED light to blink.

We started working using Fritzing to get an idea on how the Arduino would work. Then we started coding in Tinkercad.

I ended up with this code:


int LED1 = 13; //shortcut for the first LED
int LED2 = 12; //shortcut for the second LED
int LED3 = 11; //shortcut for the third LED


void setup() 
{
  pinMode(LED_BUILTIN, OUTPUT); //LED_BUILTIN output
  pinMode(LED2, OUTPUT); //digital output of LED2 pin
  pinMode(LED3, OUTPUT); //digital output of LED3
}

void LEDFlash1 (int sec) //void command with int for seconds
  {
  digitalWrite(LED1, HIGH); // LED on
  delay(sec); 
  digitalWrite(LED1, LOW); // LED off
  delay(sec);
  }

void LEDFlash2 (int sec) //clone for the second LED
  {
  digitalWrite(LED2, HIGH); //
  delay(sec); 
  digitalWrite(LED2, LOW);
  delay(sec);
  }
void LEDFlash3 (int sec) // clone for the third LED
  {
  digitalWrite(LED3, HIGH);
  delay(sec); 
  digitalWrite(LED3, LOW);
  delay(sec);
  }

void loop() //main command
{
  LEDFlash1 (10000);
}

This was just a rough draft of a working command, it originally was for three LED’s but it was change so that it work on the built in LED of the Arduino Uno Board.

*NOTE: make sure that you are only using the first void ,otherwise this could mess up with your board. If you want to be extra careful, turn the other void commands into comments by add // at the start of the line.

That was just a rough draft so it’s not at all polished, I’ll try to improve my coding so that it would be easier to read for others. That’s all for now.

P.S. I’ll try to finish last weeks post with the research I have.

codes derived from the arduino booklet. The codes, though changed are based off the codes in the booklet