///Title: D-Flipflop ///Author: Kner ///Date: 1.2.2014 ///Comment: data are stored on the rising edge of the clock signal /* two inputs: data,clock one output: q (stored data) */ #define CLOCK 12 #define DATA 13 #define Q 8 void setup() { pinMode(8,OUTPUT); pinMode(CLOCK,INPUT_PULLUP); pinMode(DATA,INPUT_PULLUP); } void loop() { uint8_t clk = digitalRead(CLOCK); while (clk == 1) clk = digitalRead(CLOCK); //wait for CLOCK to go to LOW delay(50); // debounce while (clk == 0) clk = digitalRead(CLOCK); //wait for CLOCK to go to HIGH delay(50); // debounce uint8_t dat = digitalRead(DATA); digitalWrite(Q,dat); }