Arduino: Nano test script

When testing out nano devices, you can use this script to simulate a breathing LED, this script will “breathe” on the “L” LED when uploaded:

 

/*
  Android Breath v0.2
  Simulates led breathing found on Android devices.
  Tested with Arduino Nano ATmega328.
  
  Cesar Schneider <cesschneider@gmail.com>
  https://gist.github.com/cesschneider/7689698
 */
 
// Pin 13 has an LED connected on most Arduino boards.
// give it a name:
int led = 13;

// the setup routine runs once when you press reset:
void setup() {                
  pinMode(led, OUTPUT);     
}

int i;
int on;
int off;
int pulses;
int cycles = 5;

void loop() {
  
  pulses = 8;
  for (on = 1; on <= cycles; on++) {
    for (i = 0; i < pulses; i++) {
      digitalWrite(led, HIGH);   
      delay(on);               
      digitalWrite(led, LOW);    
      delay(cycles - on);               
    }
    //  on  off  pu  cy
    // (1 + 4) * 8 * 5 = 200ms
  }
  
  pulses = 8;
  for (off = cycles; off > 1; off--) {
    for (i = 0; i < pulses; i++) {
      digitalWrite(led, HIGH);   
      delay(off);               
      digitalWrite(led, LOW);    
      delay(cycles - off);               
    }
    //  on  off  pu  cy
    // (5 + 1) * 8 * 5 = 200ms
  }

  digitalWrite(led, LOW);    
  delay(2000);               
}

It’s made by GitHUB user cesschneider, read more here:

https://gist.github.com/cesschneider/7689698

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.

Close