From 73e1b3195dad9c9a11009dc01504268a6cbea9d7 Mon Sep 17 00:00:00 2001 From: Tom Nordal Date: Mon, 24 Jun 2024 20:12:44 +0200 Subject: [PATCH] copy lesson 45 --- ShiftRegLeds/lessons/lesson45.cpp | 33 +++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 ShiftRegLeds/lessons/lesson45.cpp diff --git a/ShiftRegLeds/lessons/lesson45.cpp b/ShiftRegLeds/lessons/lesson45.cpp new file mode 100644 index 0000000..454ffd0 --- /dev/null +++ b/ShiftRegLeds/lessons/lesson45.cpp @@ -0,0 +1,33 @@ +// https://www.youtube.com/watch?v=-WDO4mi2I68&list=PLGs0VKk2DiYw-L-RibttcvK-WBZm8WLEP&index=45 + +#include + +int latchPin = 11; +int clockPin = 9; +int dataPin = 12; + +int dt = 100; +byte ledByte = 0b11111110; + + +void setup() { + // put your setup code here, to run once: + Serial.begin(9600); + pinMode(latchPin, OUTPUT); + pinMode(clockPin, OUTPUT); + pinMode(dataPin, OUTPUT); + +} + +void loop() { + // put your main code here, to run repeatedly: + digitalWrite(latchPin, LOW); + shiftOut(dataPin, clockPin, LSBFIRST, ledByte); + digitalWrite(latchPin, HIGH); + + Serial.println(ledByte, BIN); + delay(dt); + + ledByte = ledByte * 128 + ledByte / 2; // Shift right + // ledByte = ledByte / 128 + ledByte * 2; // Shift left +}