• Home
  • pcDuino
  • WiKi
  • Store
  • Distributors
  • Home
  • pcDuino
  • WiKi
  • Store
  • Distributors
HomepcDuinoThe program of Breathing Lamp on pcDuino
Previous Next

The program of Breathing Lamp on pcDuino

Posted by: admin , March 6, 2014

[vc_row][vc_column width=”1/1″][vc_tour][vc_tab title=”Introduce” tab_id=”1393987593-1-22″][vc_column_text]

Breathing lamp refers to the lights that complete gradual change from light to dark

under the control of a microcomputer or circuit , feeling like breathing.

It is Widely used in mobile phones and become one of the selling points of new phones

at each big brand .

If your phone has a pending notification, such as missed calls, unchecked message

s and so on,breathing lamp will change from dark to bright,the  is  just  like  breathing ,

and  plays  a role of notice to remind.

See here, you will find  that this post is similar to the post before,   but the program of

breathing lamp I posted before is  on Arduino, and it  could not be used on pcDuino

if move the original program directly to pcDuino , it need to do some modification.

QQ图片20140304221158

[/vc_column_text][/vc_tab][vc_tab title=”Test code” tab_id=”1393987593-2-6″][vc_column_text]

/*Notice: do not operate the pcDuino after the program is started, or the lamp may flash obvious.*/

#include"core.h"
#define SigPin 2

#define CYCLE 1500

void delay_us(int t)
{
  usleep(t);
}

void delay_ms(int t)
{
  while(--t){usleep(1000);}
}

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);
}

[/vc_column_text][/vc_tab][/vc_tour][/vc_column][/vc_row]

Tags: pcDuino

Share!
Tweet

admin

About the author

Leave a Reply Cancel reply

You must be logged in to post a comment.

Category

  • Home
  • pcDuino
  • WiKi
  • Store
  • Distributors