Hi, I recently got some CD 4035 shift registers, i'm trying to get them working with my Arduino but i'm having no success. Here is my code for shifting a 1010 pattern but i don't get anything: i have wired some led to the output for debugging, they are going all low / all high after the TRUE_COMPLEMENT_PIN change state but other than that, no pattern !! Can someone help me ? thx
// GPIO Pin definitions
#define CLK_PIN 5 // Clock pin connected to CLK of CD4035B
#define J_PIN 9 // Serial J input connected to J of CD4035B
#define K_PIN 10 // Serial K input connected to K of CD4035B
#define PARALLEL_SERIAL_PIN 6 // Parallel/Serial Control
#define TRUE_COMPLEMENT_PIN 7 // True/Complement Control
#define RESET_PIN 8 // Reset pin for CD4035B (if used)
// Function to pulse the clock signal
void pulseClock() {
digitalWrite(CLK_PIN, HIGH); // Clock high
delay(200); // Delay to give enough time for data to settle
digitalWrite(CLK_PIN, LOW); // Clock low
delay(200); // Delay before next clock cycle
}
void setup() {
// Set pins as outputs
pinMode(CLK_PIN, OUTPUT);
pinMode(J_PIN, OUTPUT);
pinMode(K_PIN, OUTPUT);
pinMode(PARALLEL_SERIAL_PIN, OUTPUT);
pinMode(TRUE_COMPLEMENT_PIN, OUTPUT);
pinMode(RESET_PIN, OUTPUT); // Setup reset pin
// Initialize to low state
digitalWrite(CLK_PIN, LOW);
digitalWrite(J_PIN, LOW);
digitalWrite(K_PIN, LOW);
digitalWrite(PARALLEL_SERIAL_PIN, LOW); // Serial mode
digitalWrite(TRUE_COMPLEMENT_PIN, HIGH); // True output mode
digitalWrite(RESET_PIN, HIGH); // Ensure the reset is not active
Serial.begin(9600);
Serial.println("CD4035B Shift Register Test");
}
// Function to shift data into the register
void shiftSerialData(bool j, bool k) {
// Write the serial data to J and K
digitalWrite(J_PIN, j); // Set J pin
digitalWrite(K_PIN, k); // Set K pin
// Print data being shifted
Serial.print("Shifting - J: ");
Serial.print(j);
Serial.print(" K: ");
Serial.println(k);
// Pulse the clock to shift the data into the first stage
pulseClock();
}
void loop() {
// Set to serial mode
digitalWrite(PARALLEL_SERIAL_PIN, LOW);
// Example: Shift a known pattern (1010) into the register
shiftSerialData(HIGH, LOW); // First stage: Set to 1 (J=1, K=0)
delay(250); // Delay for observation
shiftSerialData(LOW, HIGH); // Second stage: Set to 0 (J=0, K=1)
delay(250);
shiftSerialData(HIGH, LOW); // Third stage: Set to 1 (J=1, K=0)
delay(250);
shiftSerialData(LOW, HIGH); // Fourth stage: Set to 0 (J=0, K=1)
delay(1000);
// Toggle true/complement mode
digitalWrite(TRUE_COMPLEMENT_PIN, !digitalRead(TRUE_COMPLEMENT_PIN)); // Switch between true and complement mode
Serial.println("Toggling True/Complement");
delay(500); // Wait 5 seconds to observe the result
}