Directory Listing | |
---|---|
lab2a.ino
|
|
lab2bstud.ino
|
|
writeup.pdf
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
////////////////////////////////////////
// COSC 130, Lab 2 Template File
// Modify the functions below
//
////////////////////////////////////////
String decimal_to_bin(int input)
{
String output;
// Write the binary value of input into
// the string output
return output;
}
String decimal_to_hex(int input)
{
String output;
// Write the hex value of input into
// the string output
return output;
}
String decimal_to_oct(int input)
{
String output;
// Write the octal value of input into
// the string output
return output;
}
////////////////////////////////////////
//
// DO NOT MODIFY ANY FUNCTIONS BELOW
//
////////////////////////////////////////
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
}
void loop() {
// put your main code here, to run repeatedly:
if (Serial && (Serial.available() > 0)) {
String input = Serial.readString();
int i_input = input.toInt();
Serial.println("Dec: " + input);
Serial.println("Bin: " + decimal_to_bin(i_input));
Serial.println("Oct: " + decimal_to_oct(i_input));
Serial.println("Hex: " + decimal_to_hex(i_input));
Serial.print("\n");
}
else {
delay(115);
}
}