Skip to content

Instantly share code, notes, and snippets.

@houmei
Created May 14, 2012 10:43
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
Harpy nano + H2A nano test
/*
Harpy nano + H2A nano
[Tools]→[Board] Arduino Pro or Pro mini(3.3V/8MHz) w/ATmega328
*/
const int LED0 = 6; // HIGH
const int LEDR = 2; // LOW
const int LEDB = 3; // LOW
const int LEDG = 4; // LOW
const int SW = A0;
const int W = 80; // wait 80*8ms
void setup() {
pinMode(LED0, OUTPUT);
pinMode(LEDR, OUTPUT);
pinMode(LEDB, OUTPUT);
pinMode(LEDG, OUTPUT);
pinMode(SW, INPUT);
digitalWrite(SW, HIGH); // pullup
// turn off all-LED
digitalWrite(LED0, LOW);
digitalWrite(LEDR, HIGH);
digitalWrite(LEDG, HIGH);
digitalWrite(LEDB, HIGH);
}
void loop() {
digitalWrite(LED0, HIGH);
waitsw(W);
digitalWrite(LED0, LOW);
waitsw(W);
digitalWrite(LEDR, LOW);
waitsw(W);
digitalWrite(LEDR, HIGH);
waitsw(W);
digitalWrite(LEDG, LOW);
waitsw(W);
digitalWrite(LEDG, HIGH);
waitsw(W);
digitalWrite(LEDB, LOW);
waitsw(W);
digitalWrite(LEDB, HIGH);
waitsw(W);
}
void waitsw(int s) { // wait s*8ms(SW=OFF),s*1ms(SW=ON)
int i;
for (i=0; i<8; i++) {
if (digitalRead(SW)==LOW) {
delay(s/8);
} else {
delay(s);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment