Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // test for PCF8574T board, used for LCD interface
- // runs each line high in sequence, then all on and off a couple times
- // I use the same basic routine to figure out shift register outputs
- // feel free to take the guts from this for your code.
- #include <Wire.h>
- byte i2caddr=0x27;
- void setup() {
- Wire.begin();
- }
- void loop() {
- // run one bit high, from 0b00000001 to 0b10000000
- // for mine, 0b00001000 is the backlight control
- // bits 0b00010000 to 0b10000000 are the data bus bits 4 to 7.
- for (byte b=0;b<8;b++){
- bwrite(1<<b);
- delay (500);
- }
- // flash all pins on and off 3 times
- for (byte b=0;b<3;b++){
- bwrite(0xff);
- delay (300);
- bwrite(0x00);
- delay (300);
- }
- delay(500);
- }
- void bwrite(byte data){
- Wire.beginTransmission (i2caddr);
- Wire.write (data);
- Wire.endTransmission ();
- }
Advertisement
Add Comment
Please, Sign In to add comment