Skip to content
Browse files

safety

  • Loading branch information...
0 parents commit f5ba2059c1a1b2d615e20e90f478ef426f8fdfbb @technocake technocake committed Mar 19, 2013
Showing with 89 additions and 0 deletions.
  1. +13 −0 blinktest_ino/blinktest_ino.ino
  2. +76 −0 shiftregister_test/shiftregister_test.ino
13 blinktest_ino/blinktest_ino.ino
@@ -0,0 +1,13 @@
+#define LED 13
+
+void setup() {
+ pinMode(LED, OUTPUT);
+}
+
+void loop() {
+ digitalWrite(LED, HIGH);
+ delay(1000);
+ digitalWrite(LED, LOW);
+ delay(1000);
+}
+
76 shiftregister_test/shiftregister_test.ino
@@ -0,0 +1,76 @@
+int SER_Pin = 13; //pin 14 on the 75HC595
+int RCLK_Pin = 12; //pin 12 on the 75HC595
+int SRCLK_Pin = 8; //pin 11 on the 75HC595
+
+//How many of the shift registers - change this
+#define number_of_74hc595s 2
+
+//do not touch
+#define numOfRegisterPins number_of_74hc595s * 8
+
+boolean registers[numOfRegisterPins];
+
+void setup(){
+ pinMode(SER_Pin, OUTPUT);
+ pinMode(RCLK_Pin, OUTPUT);
+ pinMode(SRCLK_Pin, OUTPUT);
+
+
+ //reset all register pins
+ clearRegisters();
+ writeRegisters();
+}
+
+
+//set all register pins to LOW
+void clearRegisters(){
+ for(int i = numOfRegisterPins - 1; i >= 0; i--){
+ registers[i] = LOW;
+ }
+}
+
+
+//Set and display registers
+//Only call AFTER all values are set how you would like (slow otherwise)
+void writeRegisters(){
+
+ digitalWrite(RCLK_Pin, LOW);
+
+ for(int i = numOfRegisterPins - 1; i >= 0; i--){
+ digitalWrite(SRCLK_Pin, LOW);
+
+ int val = registers[i];
+ val = i%2;
+
+ digitalWrite(SER_Pin, val);
+ digitalWrite(SRCLK_Pin, HIGH);
+
+ }
+ digitalWrite(RCLK_Pin, HIGH);
+
+
+}
+
+//set an individual pin HIGH or LOW
+void setRegisterPin(int index, int value){
+ registers[index] = value;
+}
+
+
+void loop(){
+
+ setRegisterPin(0, HIGH);
+ setRegisterPin(1, HIGH);
+ setRegisterPin(2, LOW);
+ setRegisterPin(3, HIGH);
+ setRegisterPin(4, HIGH);
+ setRegisterPin(5, LOW);
+ setRegisterPin(6, HIGH);
+ setRegisterPin(7, LOW);
+
+
+
+ writeRegisters(); //MUST BE CALLED TO DISPLAY CHANGES
+ writeRegisters();
+ //Only call once after the values are set how you need.
+}

0 comments on commit f5ba205

Please sign in to comment.
Something went wrong with that request. Please try again.