classicsat

PCF8574T test

Jan 20th, 2021 (edited)
320
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. // test for PCF8574T board, used for LCD interface
  2. // runs each line high in sequence, then all on and off a couple times
  3. // I use the same basic routine to figure out shift register outputs
  4. // feel free to take the guts from this for your code.
  5.  
  6.  
  7. #include <Wire.h>
  8.  
  9. byte i2caddr=0x27;
  10.  
  11. void setup() {
  12.  
  13. Wire.begin();
  14. }
  15.  
  16. void loop() {
  17.  
  18. // run one bit high, from 0b00000001 to 0b10000000
  19. // for mine, 0b00001000 is the backlight control
  20. // bits 0b00010000 to 0b10000000 are the data bus bits 4 to 7.
  21. for (byte b=0;b<8;b++){
  22. bwrite(1<<b);
  23. delay (500);
  24. }
  25.  
  26. // flash all pins on and off 3 times
  27. for (byte b=0;b<3;b++){
  28. bwrite(0xff);
  29. delay (300);
  30. bwrite(0x00);
  31. delay (300);
  32. }
  33. delay(500);
  34. }
  35.  
  36. void bwrite(byte data){
  37.  
  38. Wire.beginTransmission (i2caddr);
  39. Wire.write (data);
  40. Wire.endTransmission ();
  41. }
Advertisement
Add Comment
Please, Sign In to add comment