Browse Source

Lesson 42 finished

master
Tom Nordal 2 years ago
parent
commit
516cf72130
  1. 32
      ShiftRegLeds/src/main.cpp

32
ShiftRegLeds/src/main.cpp

@ -1,18 +1,34 @@
// https://www.youtube.com/watch?v=n3qmQHzcgto&list=PLGs0VKk2DiYw-L-RibttcvK-WBZm8WLEP&index=42
#include <Arduino.h> #include <Arduino.h>
// put function declarations here: int latchPin = 11;
int myFunction(int, int); int clockPin = 9;
int dataPin = 12;
int dt = 2500;
byte LED1s = 0b10101010;
byte LED2s = 0b01010101;
void setup() { void setup() {
// put your setup code here, to run once: // put your setup code here, to run once:
int result = myFunction(2, 3); Serial.begin(9600);
pinMode(latchPin, OUTPUT);
pinMode(clockPin, OUTPUT);
pinMode(dataPin, OUTPUT);
} }
void loop() { void loop() {
// put your main code here, to run repeatedly: // put your main code here, to run repeatedly:
} digitalWrite(latchPin, LOW);
shiftOut(dataPin, clockPin, LSBFIRST, LED1s);
digitalWrite(latchPin, HIGH);
delay(dt);
// put function definitions here: digitalWrite(latchPin, LOW);
int myFunction(int x, int y) { shiftOut(dataPin, clockPin, LSBFIRST, LED2s);
return x + y; digitalWrite(latchPin, HIGH);
} delay(dt);
}

Loading…
Cancel
Save