Digital Electronics Week 9 assignment

BY BENNA SU

Hi here is my Arduino code.

int led[4] = {28, 29, 30, 31};
int pot = A16;
int pot2 = A17;
int potval = 0;
int potval2 = 0;
int mappedpotval = 0;
int mappedpotval2 = 0;

int currentStep = 0;
int lastSteptime = 0;





void setup() {
  for (int i = 0; i < 4; i++) {
    pinMode(led[i], OUTPUT);
  }
  Serial.begin(9600);

}

void loop() {
  digitalWrite(led[currentStep], HIGH);
  Serial.write(0);
  Serial.write(currentStep * 100);

  potval = analogRead(pot);
  mappedpotval = map(potval, 0, 1023, 100, 1000);

  if (millis() > lastSteptime + mappedpotval) {
    lastSteptime = millis();
    digitalWrite(led[currentStep], LOW);

    currentStep++;
    if (currentStep == 4) {
      currentStep = 0;
    }
  }
  delay(50);
}


Here is the Processing Code!

Here is the video. It is always showing that port is busy. I don’t know what happened.

here is the photo

留下评论

通过 WordPress.com 设计一个这样的站点
从这里开始