Learn Microcontroller From beginning #Tutorial 1

Arduino IDE software link:


Example program for blinking

// the setup function runs once when you press reset or power the board

void setup()
 {
  // initialize digital pin 13 as an output.
  pinMode(13, OUTPUT);
}

// the loop function runs over and over again forever

void loop() 
{
  digitalWrite(13, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);              // wait for a second
  digitalWrite(13, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);              // wait for a second
}

Circuit Diagram

For connecting 3 LED's

Program:

void setup()
{
  pinMode(11, OUTPUT);
  pinMode(12, OUTPUT);
  pinMode(13, OUTPUT);
}
void loop()
{  
  digitalWrite(11, HIGH);
  digitalWrite(12, HIGH);
  digitalWrite(13, HIGH);
  delay(1000);                
  digitalWrite(11, LOW);
  digitalWrite(12, LOW);
  digitalWrite(13, LOW);
  delay(1000);            

  • In this connection they used 6 LED's there is 13 digital outputs are available so we can generate 13 different PWM pulses
  • Watch this tutorial video 


Comments

Popular Posts