This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | |||
notes:c4eng:fall2023:projects:ptb1 [2023/10/19 02:43] – mwinter4 | notes:c4eng:fall2023:projects:ptb1 [2023/10/19 02:54] (current) – mwinter4 | ||
---|---|---|---|
Line 32: | Line 32: | ||
=====LOGIC===== | =====LOGIC===== | ||
- | Synopsis: | + | **Synopsis:** |
To achieve our desired outcome with only one if statement, we'll need to implement bit shifting and a for loop. | To achieve our desired outcome with only one if statement, we'll need to implement bit shifting and a for loop. | ||
- | It would also be helpful, first, to create an array. | + | It would also be helpful, first, to create an array if our pins are not connected sequentially. |
=====ARRAYS IN C===== | =====ARRAYS IN C===== | ||
+ | To declare an array in C is similar to declaring any variable: we declare the data type (in arrays, the data type of all the elements), name the variable, and assign a value (or a matrix of values for arrays). | ||
+ | |||
+ | < | ||
+ | int myArray[10] = {5, | ||
+ | </ | ||
+ | |||
+ | In our sample, 10 is the number of elements we have (not shown). |