• Home
  • pcDuino
  • WiKi
  • Store
  • Distributors
  • Home
  • pcDuino
  • WiKi
  • Store
  • Distributors
HomeArduinoBreathing light – using Arduino board
Previous Next

Breathing light – using Arduino board

Posted by: Alvin Jin , March 5, 2014

Breathing light is a status light really, also used for notification if a new message arrives or perhaps if you missed a phone call. you might want to consider turning it off if you are concerned with battery life as it does use a bit more, tho i am not sure if it is that significant.

1

 

Source code

#include"arduino.h"
#include <util/delay.h>
#define SigPin 2
#define CYCLE 1500
void setup() {
  // put your setup code here, to run once:
  pinMode(SigPin,OUTPUT);
  digitalWrite(SigPin,LOW);
}
void loop() {
  int count;
  // put your main code here, to run repeatedly:
  digitalWrite(SigPin,LOW);
  _delay_ms(600);
  for(count=1;count<CYCLE;count++)
  {
     digitalWrite(SigPin,HIGH);
     _delay_us(count);
     digitalWrite(SigPin,LOW);
     _delay_us(CYCLE-count);
  }
  digitalWrite(SigPin,HIGH);
  for(count=CYCLE-1;count>0;count--)
  {
    digitalWrite(SigPin,HIGH);
    _delay_us(count);
    digitalWrite(SigPin,LOW);
   _delay_us(CYCLE-count);
  }
  _delay_ms(600);
}

Tags: Arduino

Share!
Tweet

Alvin Jin

About the author

Leave a Reply Cancel reply

You must be logged in to post a comment.

Category

  • Home
  • pcDuino
  • WiKi
  • Store
  • Distributors