Code Club Electronics 8

So following on from the previous post. I had to look this up to remind myself how to specific a pin. Not used Arduino in a while. I found the following code as part of a stackoverflow post

However, in this, the two LEDs flash on and off alternately. Delay is set by a single line.

int delayPeriod = 1000;

So this is more so I can learn how to specify a pin.

int ledPin = 12;
int ledPin2 = 13;
int delayPeriod = 1000;

void setup()
{
  pinMode(ledPin, OUTPUT);
  pinMode(ledPin2, OUTPUT);
}

void loop()
{
  digitalWrite(ledPin, HIGH);
  digitalWrite(ledPin2,LOW);
  delay(delayPeriod);
  digitalWrite(ledPin2, HIGH);
  digitalWrite(ledPin,LOW);
  delay(delayPeriod);
  //delayPeriod = delayPeriod - 10;
}

In the video, I am just changing a single line of code to cause the delay.

Timings are in milliseconds or seconds

Links

Tags

#Electronics,#Code,#Arduino,#Hacking.#LED,#Blink


MastodonPeertubeQoto sign up

Donate using Liberapay