User:Redstone guy/sandbox

This page is owned by and was created by Redstone guy. Permission to edit this page is required from owner. Here are my ideas for Arduino UNO: ————————————————————————————————————————————————————————————————————————————————————— ARDUINO UNO COUNTER: const int Up = 2; const int In1 = 3; const int In2 = 4; const int In4 = 5; const int In8 = 6; const int Set = 7; const int Down = 8; const int QA = 9; const int QB = 10; const int QC = 11; const int QD = 12; const int Reset = 13; int counter = 15; void setup { pinMode(Up, INPUT); pinMode(Down, INPUT); pinMode(In1, INPUT); pinMode(In2, INPUT); pinMode(In4, INPUT); pinMode(In8, INPUT); pinMode(Set, INPUT); pinMode(Reset, INPUT); pinMode(QA, OUTPUT); pinMode(QB, OUTPUT); pinMode(QC, OUTPUT); pinMode(QD, OUTPUT); digitalWrite (QA, LOW); digitalWrite (QB, LOW); digitalWrite (QC, LOW); digitalWrite (QD, LOW); counter = 0; } void loop { check ; } void up  { while (digitalRead(Up) == LOW) {} delay (50); while (digitalRead(Up) == HIGH){ ++counter; } delay (50); } void down { while (digitalRead(Down) == LOW) {} delay (50); while (digitalRead(Down) == HIGH){ --counter; } delay (50); } void check { if (counter == 0){ digitalWrite (QA, LOW); digitalWrite (QB, LOW); digitalWrite (QC, LOW); digitalWrite (QD, LOW); } else if (counter == 1){ digitalWrite (QA, HIGH); digitalWrite (QB, LOW); digitalWrite (QC, LOW); digitalWrite (QD, LOW); } else if (counter == 2){ digitalWrite (QA, LOW); digitalWrite (QB, HIGH); digitalWrite (QC, LOW); digitalWrite (QD, LOW); } else if (counter == 3){ digitalWrite (QA, HIGH); digitalWrite (QB, HIGH); digitalWrite (QC, LOW); digitalWrite (QD, LOW); } else if (counter == 4){ digitalWrite (QA, LOW); digitalWrite (QB, LOW); digitalWrite (QC, HIGH); digitalWrite (QD, LOW); } else if (counter == 5){ digitalWrite (QA, HIGH); digitalWrite (QB, LOW); digitalWrite (QC, HIGH); digitalWrite (QD, LOW); } else if (counter == 6){ digitalWrite (QA, LOW); digitalWrite (QB, HIGH); digitalWrite (QC, HIGH); digitalWrite (QD, LOW); } else if (counter == 7){ digitalWrite (QA, HIGH); digitalWrite (QB, HIGH); digitalWrite (QC, HIGH); digitalWrite (QD, LOW); } else if (counter == 8){ digitalWrite (QA, LOW); digitalWrite (QB, LOW); digitalWrite (QC, LOW); digitalWrite (QD, HIGH); } else if (counter == 9){ digitalWrite (QA, HIGH); digitalWrite (QB, LOW); digitalWrite (QC, LOW); digitalWrite (QD, HIGH); } else if (counter == 10){ digitalWrite (QA, LOW); digitalWrite (QB, HIGH); digitalWrite (QC, LOW); digitalWrite (QD, HIGH); } else if (counter == 11){ digitalWrite (QA, HIGH); digitalWrite (QB, HIGH); digitalWrite (QC, LOW); digitalWrite (QD, HIGH); } else if (counter == 12){ digitalWrite (QA, LOW); digitalWrite (QB, LOW); digitalWrite (QC, HIGH); digitalWrite (QD, HIGH); } else if (counter == 13){ digitalWrite (QA, HIGH); digitalWrite (QB, LOW); digitalWrite (QC, HIGH); digitalWrite (QD, HIGH); } else if (counter == 14){ digitalWrite (QA, LOW); digitalWrite (QB, HIGH); digitalWrite (QC, HIGH); digitalWrite (QD, HIGH); } else if (counter == 15){ digitalWrite (QA, HIGH); digitalWrite (QB, HIGH); digitalWrite (QC, HIGH); digitalWrite (QD, HIGH); } } void reset { while (digitalRead(Reset) == LOW) {} delay (50); while (digitalRead(Reset) == HIGH){ counter = 0; } delay (50); } void set { while (digitalRead(Set) == LOW) {} delay (50); while (digitalRead(Set) == HIGH){ digitalWrite (QA, digitalRead(In1)); digitalWrite (QB, digitalRead(In2)); digitalWrite (QC, digitalRead(In4)); digitalWrite (QD, digitalRead(In8)); } delay (50); } ————————————————————————————————————————————————————————————————————————————————————— ARDUINO UNO TOGGLE FLIP-FLOP: const int NotQ = 9; const int Q = 10; const int IN = A0; void setup { pinMode (NotQ, OUTPUT); pinMode (Q, OUTPUT); pinMode (IN, INPUT); digitalWrite (NotQ, HIGH); digitalWrite (Q, LOW); } void loop { while (digitalRead(IN) == LOW) {} delay (50); while (digitalRead(IN) == HIGH){ digitalWrite (NotQ, LOW); digitalWrite (Q, HIGH); } delay (50); while (digitalRead(IN) == LOW) {} delay (50); while (digitalRead(IN) == HIGH){ digitalWrite (Q, LOW); digitalWrite (NotQ, HIGH); } delay (50); } —————————————————————————————————————————————————————————————————————————————————————