/*
* Bit Operations
* This program is divided into tabs
* Tabs help organize a program into pages
* Each tab contains logically connected portions
* of the program.
* We are using the tabs to break down the program
* into four different sections in addition to the
* main program on this tab.
* Tabs make troubleshooting easier in that each page
* can be looked at separately instead of trying to
* go down a very long list on only one page.
* In this case, three separate programs (related in that
* they use the same LED setup and push button and all
* are logic operations
*
* Connections:
* pin Terminal Block
2 41 (rightmost red for lsb)
3 40
4 39
5 38 (leftmost red for msb
6 45 (lsb yellow)
7 44
8 43
9 42 (msb yellow)
10 49 (lsb green)
11 48
12 47
13 46 (msb green)
A0 24 (Push button 1) (A0 is digital input 14)
*
*
* See documentation under each tab for info on the functions for that tab
*
* Created by Ron Ropson on July 9, 2020
*
*/
const byte binary_in_A=B00000011; // The "B" before the number tells the program that this is a binary number.
const byte binary_in_B=B00000101; // Since these are constants, we can't change them in the program.
const byte pushButton=14;// Our push button must be attached to A0, which is digital pin 14
byte binary_out_X;// We don't have to specify a value because this is an output.
byte zero=48; // The number zero is 48 ascii.
byte incomingByte;
byte bitout;
void setup()
{
Serial.begin(9600); //Open the serial port for monitoring.
for(byte a=2;a<14;a++) //Set all pins for output using the for loop.
{
pinMode(a,OUTPUT);
}
pinMode(pushButton,INPUT_PULLUP); // for bit shift operations
}
void loop()
{
printMenu();
char choice = 0;
choice = waitForInt(1,4);
switch (choice)
{
case 1:booleanFunction();break;
case 2:bitShiftFunction();break;
case 3:binaryMathFunction();break;
case 4:chaserFunction();break;
}
}
// ********************************** Functions *************************************
void printMenu()
{
Serial.println("");
Serial.println(F("Please choose from the following:"));
Serial.println("");
Serial.println(F("1 Boolean Operations"));
Serial.println(F("2 Bit Shifting Operations"));
Serial.println(F("3 Integer Math"));
Serial.println(F("4 Light Chaser Program"));
Serial.println("");
}
void chaserFunction()
{
// empty, does nothing.User will make new tab
// and put this function in the new tab\
// user will also utilize existing functions from other tabs
// to simplify programming
}