Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <SPI.h>
- #include <LiquidCrystal.h>
- #include <glcd.h>
- #include <fonts/allFonts.h>
- #define out1 2
- #define out2 3
- #define out3 4
- #define in 5
- #define button 10
- unsigned int KMAP[2][4];
- String BOOL = "";
- String Old = "1";
- int A;
- String TEST = "Test";
- void setup()
- /* This section sets up the intial conditions required to execute
- / all subsequent functions, mostly setting the pins as input
- / and output and intializing the LCD libraries.
- */
- {
- GLCD.Init(); //Initialize the graphic LCD
- GLCD.SelectFont(System5x7); //Select the 5x7 font
- pinMode(out1, OUTPUT); //Set these pins to output
- pinMode(out2, OUTPUT);
- pinMode(out3, OUTPUT);
- pinMode(in, INPUT); //Set these pins to input
- pinMode(button, INPUT);
- //digitalWrite(button, HIGH); //Turn on internal pullup resistor
- Serial.begin(9600); //Start serial communication
- Serial.println("Serial begin."); //Print the test line
- }
- void loop()
- {
- if (digitalRead(10) == HIGH){
- BOOL = "";
- digitalWrite(out1, LOW); //Output C
- digitalWrite(out2, LOW); //Output B
- digitalWrite(out3, LOW); //Output A
- delay(10);
- KMAP[0][0] = digitalRead(in); //A'B'C'
- digitalWrite(out1, HIGH);
- delay(10);
- KMAP[1][0] = digitalRead(in); //A'B'C
- digitalWrite(out1, LOW);
- digitalWrite(out2, HIGH);
- delay(10);
- KMAP[0][1] = digitalRead(in); //A'BC'
- digitalWrite(out1, HIGH);
- delay(10);
- KMAP[1][1] = digitalRead(in); //A'BC
- digitalWrite(out1, LOW);
- digitalWrite(out2, LOW);
- digitalWrite(out3, HIGH);
- delay(10);
- KMAP[0][3] = digitalRead(in); //AB'C'
- digitalWrite(out1, HIGH);
- delay(10);
- KMAP[1][3] = digitalRead(in); //AB'C
- digitalWrite(out1, LOW);
- digitalWrite(out2, HIGH);
- delay(10);
- KMAP[0][2] = digitalRead(in); //ABC'
- digitalWrite(out1, HIGH);
- delay(10);
- KMAP[1][2] = digitalRead(in); //ABC
- if (KMAP[0][0] && KMAP[1][0] && KMAP[0][3] && KMAP[1][3]) {
- BOOL += "+ B'";
- }
- if (KMAP[0][0] && KMAP[1][0] && KMAP[0][1] && KMAP[1][1]) {
- BOOL += "+ A' ";
- }
- if (KMAP[0][1] && KMAP[1][1] && KMAP[0][2] && KMAP[1][2]) {
- BOOL += "+ B ";
- }
- if (KMAP[0][2] && KMAP[1][2] && KMAP[0][3] && KMAP[1][3]) {
- BOOL += "+ A ";
- }
- if (KMAP[0][0] && KMAP[0][1] && KMAP[0][2] && KMAP[0][3]) {
- BOOL += "+ C'";
- }
- if (KMAP[1][0] && KMAP[1][1] && KMAP[1][2] && KMAP[1][3]) {
- BOOL += "+ C";
- }
- if (KMAP[0][0] && KMAP[1][0]) {
- BOOL += "+ A'B' ";
- }
- if (KMAP[0][1] && KMAP[1][1]) {
- BOOL += "+ A'B ";
- }
- if (KMAP[0][2] && KMAP[1][2]) {
- BOOL += "+ AB ";
- }
- if (KMAP[0][3] && KMAP[1][3]) {
- BOOL += "+ AB' ";
- }
- if (KMAP[0][0]) {
- BOOL += "+ A'B'C' ";
- }
- if (KMAP[1][0]) {
- BOOL += "+ A'B'C ";
- }
- if (KMAP[0][1]) {
- BOOL += "+ A'BC' ";
- }
- if (KMAP[1][1]) {
- BOOL += "+ A'BC ";
- }
- if (KMAP[0][2]) {
- BOOL += "+ ABC' ";
- }
- if (KMAP[1][2]) {
- BOOL += "+ ABC ";
- }
- if (KMAP[0][3]) {
- BOOL += "+ AB'C' ";
- }
- if (KMAP[1][3]) {
- BOOL += "+ AB'C ";
- }
- if (Old != BOOL) {
- Serial.println(BOOL);
- Old = BOOL;
- delay(1000);
- }
- }
- }
- void READ()
- /* This section is the read and store section; it interacts with
- / the outside world via the designated output and input pins.
- / This section will write to each output, counting up in binary
- / with the MSB called A, and the LSB called C.
- */
- {
- }
- void CONV()
- /* This is the Karnaugh mapping section, which checks for contiguous
- / sections of true outputs on a grid created in the array BOOL.
- / This simplifies the expression by eliminating variables whose level
- / is irrelevant because the output is true when it is true or false.
- */
- {
- }
- void DISP()
- {
- }
Add Comment
Please, Sign In to add comment