Outils pour utilisateurs

Outils du site


start:arduino:74hc595:programmes

Ceci est une ancienne révision du document !


Table des matières

Programmes Arduino pour 74HC595

Prog1.ino
/*
  ShiftRegister74HC595 - Library for simplified control of 74HC595 shift registers.
  Developed and maintained by Timo Denk and contributers, since Nov 2014.
  Additional information is available at https://timodenk.com/blog/shift-register-arduino-library/
  Released into the public domain.
*/
 
#include <ShiftRegister74HC595.h>
 
// create a global shift register object
// parameters: <number of shift registers> (data pin, clock pin, latch pin)
ShiftRegister74HC595<1> sr(0, 1, 2);
 
void setup() { 
}
 
void loop() {
 
  // setting all pins at the same time to either HIGH or LOW
  sr.setAllHigh(); // set all pins HIGH
  delay(500);
 
  sr.setAllLow(); // set all pins LOW
  delay(500); 
 
 
  // setting single pins
  for (int i = 0; i < 8; i++) {
 
    sr.set(i, HIGH); // set single pin HIGH
    delay(250); 
  }
 
 
  // set all pins at once
  uint8_t pinValues[] = { B10101010 }; 
  sr.setAll(pinValues); 
  delay(1000);
 
 
  // read pin (zero based, i.e. 6th pin)
  uint8_t stateOfPin5 = sr.get(5);
  sr.set(6, stateOfPin5);
 
 
  // set pins without immediate update
  sr.setNoUpdate(0, HIGH);
  sr.setNoUpdate(1, LOW);
  // at this point of time, pin 0 and 1 did not change yet
  sr.updateRegisters(); // update the pins to the set values
}
/home/chanteri/www/fablab37110/data/attic/start/arduino/74hc595/programmes.1646733603.txt.gz · Dernière modification : 2023/01/27 16:08 (modification externe)