Sha256: c1a24b0d781c714af84c27a9b5827565abf57336ffe93e03e8800d2a1fe44d75

Contents?: true

Size: 657 Bytes

Versions: 2

Compression:

Stored size: 657 Bytes

Contents

int LENGTH = 3;

int ledPins[] = {12, 11, 10};
int buttonPins[] = {5, 4, 3};
int channelIds[] = {0, 32, 8};

void setup() {
  Serial.begin(9600);
  for (int i = 0; i < LENGTH; ++i) {
    pinMode(ledPins[i], OUTPUT);
    pinMode(buttonPins[i], INPUT);
  }
}

void loop() {
  for (int i = 0; i < LENGTH; ++i) {
    if (digitalRead(buttonPins[i])) {
      turnOnLed(i);
    }
  }

  delay(1);
}

void turnOnLed(int which) {
  for (int i = 0; i < LENGTH; ++i) {
    if (i == which) {
      digitalWrite(ledPins[i], HIGH);
      Serial.println(channelIds[i]);
      Serial.flush();
    } else {
      digitalWrite(ledPins[i], LOW);
    }
  }
  
  delay(1000);
}

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
douban.fm.arduino-0.1.0 douban_fm/douban_fm.ino
douban.fm.arduino-0.0.2 douban_fm/douban_fm.ino