I am try to shift out 16bits data when PGb is low and Vpg is high. Now have no ideal how to code the data and shift out.
Any suggesting? And also try to switch back PGb to High and Vpg to Low forever after PGb stay on Low for 2s.
Thanks
// Name : Temp Sensor Code
int PGb = 8; //latchPinB
int Clk = 12;
int Din = 11;
int Dout = 10;
int Vpg = 9;
int Data = AA55; // 16 bits data 10101010,01010101 ??
void setup(){
pinMode(PGb, OUTPUT);
pinMode(Clk, OUTPUT);
pinMode(Din, OUTPUT);
pinMode(Vpg, OUTPUT);
pinMode(Dout, INPUT);
}
void loop(){
digitalWrite(PGb, HIGH);
digitalWrite(Vpg, LOW);
for(int i = 0; i < 16; i++ ){
shiftOut(Din, Clk, LSBFIRST, Data);
}
digitalWrite(PGb, LOW);
digitalWrite(Vpg, HIGH);
delay(2000);
digitalWrite(PGb, HIGH);
digitalWrite(Vpg, LOW);
}
doaway:
However, there is an error <no matching function for call to SPIClass::begin(int)>.
That's a pretty clear error message; the begin function doesn't accept an int argument (Assuming you are not using a Due), so why are you trying to pass it one.
doaway:
However, there is an error <no matching function for call to SPIClass::begin(int)>.
That's a pretty clear error message; the begin function doesn't accept an int argument (Assuming you are not using a Due), so why are you trying to pass it one.
Yes, I am using uno. Here is an example on Arduino for Due, but no uno...
void setup(){
// initialize the bus for the device on pin 4
SPI.begin(4);
// Set clock divider on pin 4 to 21
SPI.setClockDivider(4, 21);
// initialize the bus for the device on pin 10
SPI.begin(10);
// Set clock divider on pin 10 to 84
SPI.setClockDivider(10, 84);
}
Hi Nick, I want to shift 16 bits data to a 16 bit series in-parallel out shift register.
Here is my code, I connect pin12 to oscillator, pin11 to multimeter, I did not see a waveform on the oscillator and 0 voltage on multimeter.
Maybe my code does not work.
int PGb = 8; //latchPinB
int Clk = 12;
int Din = 11;
int Dout = 10;
int Vpg = 9;
// byte Data0 = B00000000; // 16 bits data
// byte Data1 = B11111111;
int Data = 500;
void setup(){
pinMode(PGb, OUTPUT);
pinMode(Clk, OUTPUT);
pinMode(Din, OUTPUT);
pinMode(Vpg, OUTPUT);
pinMode(Dout, INPUT);
shift();
}
void shift(){
digitalWrite(PGb, HIGH);
digitalWrite(Vpg, LOW);
shiftOut(Din, Clk, LSBFIRST, Data);
shiftOut(Din, Clk, LSBFIRST, (Data>>8));
digitalWrite(PGb, LOW);
digitalWrite(Vpg, HIGH);
delay(1000);
digitalWrite(PGb, HIGH);
digitalWrite(Vpg, LOW);
}
void loop(){
}