0% found this document useful (0 votes)
79 views6 pages

74HC595

The document describes the code for controlling an 8-bit shift register using an Arduino. It defines pins for the latch, clock, and data connections. It initializes these pins as outputs and sets an initial value of 0 for the LEDs variable. The code then uses shiftOut to sequentially set each bit and update the shift register, lighting up the LEDs one by one with a 500ms delay between each step.

Uploaded by

Widhi Ari Yudha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
79 views6 pages

74HC595

The document describes the code for controlling an 8-bit shift register using an Arduino. It defines pins for the latch, clock, and data connections. It initializes these pins as outputs and sets an initial value of 0 for the LEDs variable. The code then uses shiftOut to sequentially set each bit and update the shift register, lighting up the LEDs one by one with a 500ms delay between each step.

Uploaded by

Widhi Ari Yudha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

CODING

int latchPin = 5; // Latch pin of 74HC595 is connected to Digital pin 5

int clockPin = 6; // Clock pin of 74HC595 is connected to Digital pin 6

int dataPin = 4; // Data pin of 74HC595 is connected to Digital pin 4

byte leds = 0; // Variable to hold the pattern of which LEDs


are currently turned on or off

/*

* setup() - this function runs once when you turn your Arduino on

* We initialize the serial connection with the computer

*/

void setup()

// atur pin 11,12,14 pada 74HC595 sebagai OUTPUT

pinMode(latchPin, OUTPUT);

pinMode(dataPin, OUTPUT);

pinMode(clockPin, OUTPUT);

/*

* loop() - this function runs over and over again

*/

void loop()

leds = 0; // Initially turns all the LEDs off, by giving the variable
'leds' the value 0
updateShiftRegister();

delay(500);

for (int i = 0; i < 8; i++) // Turn all the LEDs ON one by one.

bitSet(leds, i); // Set the bit that controls that LED in


the variable 'leds'

updateShiftRegister();

delay(500);

/*

* updateShiftRegister() - This function sets the latchPin to low, then


calls the Arduino function 'shiftOut' to shift out contents of variable
'leds' in the shift register before putting the 'latchPin' high again.

*/

void updateShiftRegister()

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, LSBFIRST, leds);

digitalWrite(latchPin, HIGH);

ERROR

Arduino: 1.8.13 (Windows 10), Board: "Arduino Uno"

C:\Program Files (x86)\Arduino\arduino-builder -dump-prefs -logger=machine -hardware C:\Program


Files (x86)\Arduino\hardware -tools C:\Program Files (x86)\Arduino\tools-builder -tools C:\Program Files
(x86)\Arduino\hardware\tools\avr -built-in-libraries C:\Program Files (x86)\Arduino\libraries -libraries
C:\Users\LENOVO\Documents\Arduino\libraries -fqbn=arduino:avr:uno -ide-version=10813 -build-path
C:\Users\LENOVO\AppData\Local\Temp\arduino_build_573344 -warnings=none -build-cache
C:\Users\LENOVO\AppData\Local\Temp\arduino_cache_417381
-prefs=build.warn_data_percentage=75 -prefs=runtime.tools.arduinoOTA.path=C:\Program Files
(x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.arduinoOTA-1.3.0.path=C:\Program Files
(x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avrdude.path=C:\Program Files
(x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avrdude-6.3.0-arduino17.path=C:\Program Files
(x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avr-gcc.path=C:\Program Files
(x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avr-gcc-7.3.0-atmel3.6.1-
arduino7.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -verbose
D:\Instrumentasi\74HC595\74HC595.ino

C:\Program Files (x86)\Arduino\arduino-builder -compile -logger=machine -hardware C:\Program Files


(x86)\Arduino\hardware -tools C:\Program Files (x86)\Arduino\tools-builder -tools C:\Program Files
(x86)\Arduino\hardware\tools\avr -built-in-libraries C:\Program Files (x86)\Arduino\libraries -libraries
C:\Users\LENOVO\Documents\Arduino\libraries -fqbn=arduino:avr:uno -ide-version=10813 -build-path
C:\Users\LENOVO\AppData\Local\Temp\arduino_build_573344 -warnings=none -build-cache
C:\Users\LENOVO\AppData\Local\Temp\arduino_cache_417381
-prefs=build.warn_data_percentage=75 -prefs=runtime.tools.arduinoOTA.path=C:\Program Files
(x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.arduinoOTA-1.3.0.path=C:\Program Files
(x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avrdude.path=C:\Program Files
(x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avrdude-6.3.0-arduino17.path=C:\Program Files
(x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avr-gcc.path=C:\Program Files
(x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avr-gcc-7.3.0-atmel3.6.1-
arduino7.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -verbose
D:\Instrumentasi\74HC595\74HC595.ino

Using board 'uno' from platform in folder: C:\Program Files (x86)\Arduino\hardware\arduino\avr

Using core 'arduino' from platform in folder: C:\Program Files (x86)\Arduino\hardware\arduino\avr

Detecting libraries used...

"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11


-fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-
error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10813
-DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-IC:\\Program Files
(x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino" "-IC:\\Program Files
(x86)\\Arduino\\hardware\\arduino\\avr\\variants\\standard"
"C:\\Users\\LENOVO\\AppData\\Local\\Temp\\arduino_build_573344\\sketch\\74HC595.ino.cpp" -o
nul -DARDUINO_LIB_DISCOVERY_PHASE

Generating function prototypes...

"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11


-fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-
error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10813
-DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-IC:\\Program Files
(x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino" "-IC:\\Program Files
(x86)\\Arduino\\hardware\\arduino\\avr\\variants\\standard"
"C:\\Users\\LENOVO\\AppData\\Local\\Temp\\arduino_build_573344\\sketch\\74HC595.ino.cpp" -o
"C:\\Users\\LENOVO\\AppData\\Local\\Temp\\arduino_build_573344\\preproc\\ctags_target_for_gcc_
minus_e.cpp" -DARDUINO_LIB_DISCOVERY_PHASE

"C:\\Program Files (x86)\\Arduino\\tools-builder\\ctags\\5.8-arduino11/ctags" -u --language-force=c++


-f - --c++-kinds=svpf --fields=KSTtzns --line-directives
"C:\\Users\\LENOVO\\AppData\\Local\\Temp\\arduino_build_573344\\preproc\\ctags_target_for_gcc_
minus_e.cpp"

Compiling sketch...

"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11


-fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-
error=narrowing -MMD -flto -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10813
-DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-IC:\\Program Files
(x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino" "-IC:\\Program Files
(x86)\\Arduino\\hardware\\arduino\\avr\\variants\\standard"
"C:\\Users\\LENOVO\\AppData\\Local\\Temp\\arduino_build_573344\\sketch\\74HC595.ino.cpp" -o
"C:\\Users\\LENOVO\\AppData\\Local\\Temp\\arduino_build_573344\\sketch\\74HC595.ino.cpp.o"

Compiling libraries...

Compiling core...
Using precompiled core:
C:\Users\LENOVO\AppData\Local\Temp\arduino_cache_417381\core\core_arduino_avr_uno_0c81287
5ac70eb4a9b385d8fb077f54c.a

Linking everything together...

"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/bin/avr-gcc" -w -Os -g -flto -fuse-linker-plugin


-Wl,--gc-sections -mmcu=atmega328p -o
"C:\\Users\\LENOVO\\AppData\\Local\\Temp\\arduino_build_573344/74HC595.ino.elf"
"C:\\Users\\LENOVO\\AppData\\Local\\Temp\\arduino_build_573344\\sketch\\74HC595.ino.cpp.o"
"C:\\Users\\LENOVO\\AppData\\Local\\Temp\\arduino_build_573344/..\\arduino_cache_417381\\core
\\core_arduino_avr_uno_0c812875ac70eb4a9b385d8fb077f54c.a" "-
LC:\\Users\\LENOVO\\AppData\\Local\\Temp\\arduino_build_573344" -lm

"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/bin/avr-objcopy" -O ihex -j .eeprom --set-


section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0
"C:\\Users\\LENOVO\\AppData\\Local\\Temp\\arduino_build_573344/74HC595.ino.elf"
"C:\\Users\\LENOVO\\AppData\\Local\\Temp\\arduino_build_573344/74HC595.ino.eep"

"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/bin/avr-objcopy" -O ihex -R .eeprom


"C:\\Users\\LENOVO\\AppData\\Local\\Temp\\arduino_build_573344/74HC595.ino.elf"
"C:\\Users\\LENOVO\\AppData\\Local\\Temp\\arduino_build_573344/74HC595.ino.hex"

"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/bin/avr-size" -A


"C:\\Users\\LENOVO\\AppData\\Local\\Temp\\arduino_build_573344/74HC595.ino.elf"

Sketch uses 1072 bytes (3%) of program storage space. Maximum is 32256 bytes.

Global variables use 10 bytes (0%) of dynamic memory, leaving 2038 bytes for local variables. Maximum
is 2048 bytes.

Serial port not selected.


C:\\Users\\LENOVO\\AppData\\Local\\Temp\\arduino_build_573344/74HC595.ino.hex

You might also like