Hello interested person! You may be wondering what type of article this is, well worry no more! This article tells the mysteries of Binary, and a project called Binary Counter. Well, many of you out there have probably (hopefully) heard of the word Binary. BUT, do you know what it actually is? Many, whom are curious, usually ask the question...
What is Binary?
Well dear user, Binary by definition is a whole composed of, or involving, two. Binary to computers are equivalent to counting numbers to humans (kinda)! Binary is the language of love to computers, in which they comprehend/read files through Binary
Counting with Binary
Binary Counter
Breaking down binary_counter_code
- The int button states at the top define
four integers and their initial values are 0
- The four lines of code that say pinMode
set the four pin holes that your using as inputs
- The next line that says Serial.begin(115200)
initializes the serial monitor
- The first part of the void loop tells the
sidekick to read whether or not the buttons are being pressed down or not and
if it is pressed down then the value of the integer is now 1.
Serial.println
Serial.println tells the sidekick to print whatever is in the following parentheses to the serial monitor.
Inside the parentheses under Serial.println says that it takes the value of whichever button is at pin 61 (buttonState) and then adds the value of the button at pin 60 (buttonState1) but the value of buttonState1 is shifted over one place. It then adds the value at buttonState2 and shifts that value over 2 places and adds the value of buttonState3 and shifts that value over 3 places. Now that it has a value in each place it converts it to binary.
So if buttonState has a value of 1 (because it is pushed down) and the rest of the values are zero because the buttons are pressed down it is 0001 and when converted into binary the value is just 1.
Another example would be buttonState1 and buttonState2 being pressed down and it would be 0110 and when converted into binary, the value would be 6.
Hardware required:
- TI Launchpad MSP432 P401R (recommended) OR TI Launchpad MSP430 F5529 (shown in overview)
- Sidekick Basic Kit for Arduino
- Micro-USB cable
Software required:
- Energia (http://energia.nu/download/)
Comments
Please log in or sign up to comment.