InnoVech
Published

Lesson 8 - Subroutines

In this lesson we will be learning how to write programs more efficiently using programming techniques such as subroutines.

IntermediateProtip1 hour20,576
Lesson 8 - Subroutines

Things used in this project

Story

Read more

Code

Subroutines

Arduino
Lesson 8 Source Code
//Complete Guide to Arduino
//Created by Zaqyas Mahmood, InnoVech
//Lesson 8 Subroutines


#include <TimerOne.h>
#include <MultiFuncShield.h>

const int LED = 13;
int Count = 0;

void setup() {
  pinMode(LED, OUTPUT);
  Timer1.initialize();
  MFS.initialize(&Timer1);
}

void loop() {
  if (Count < 10) {
    Blink(100);
  }

  else if(Count > 10 || Count < 20){
    Blink(500);
  }

  else{
    digitalWrite(LED, HIGH);
  }
}

void Blink(int t){
  digitalWrite(LED, HIGH);  
  delay(t);               
  digitalWrite(LED, LOW);   
  delay(t);               
  Count ++;                 
  MFS.write(Count);       
}

Credits

InnoVech
11 projects • 8 followers
We strive to share our projects with engineering hobbyists and students who are driven to play their roles in the future of engineering.

Comments