This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
notes:c4eng:fall2023:projects:ptb1 [2023/10/19 02:18] – mwinter4 | notes:c4eng:fall2023:projects:ptb1 [2023/10/19 02:54] (current) – mwinter4 | ||
---|---|---|---|
Line 9: | Line 9: | ||
This will populate the ptb1 directory with all source files that you'll need for this project. | This will populate the ptb1 directory with all source files that you'll need for this project. | ||
+ | It's important to note, that while you'll be grabbing the source files via lab46, the required dependencies will not be available there and you will have to retrieve these files from your pi. | ||
+ | |||
+ | You can push these source files from your repository using the following set of commands: | ||
+ | < | ||
+ | hg add * | ||
+ | hg commit -m "YOUR COMMIT MESSAGE HERE" | ||
+ | hg push | ||
+ | </ | ||
+ | |||
+ | Assuming you've encountered no errors, you should now be able to retrieve these files on your pi: | ||
+ | < | ||
+ | hg pull | ||
+ | hg update | ||
+ | </ | ||
=====PARTS===== | =====PARTS===== | ||
Line 15: | Line 29: | ||
====button==== | ====button==== | ||
each button should be wired the same way, just to different pins. each button needs a 3.3v ran through a 10Kohm resistor and a ground wire, with a final wire with a 10kohm resistor to a gpio pin. Within wiringpi, the pin must be set to input mode. The gpio wire should also be on the opposite side of the 3.3v wire and the ground wire. You made need to switch which pin your wires are connected to if your button is not working properly. You can also check if the button is working by looking at the gpio readall table before and after the button is being pressed, and you should see a change in voltage for that gpio pin (reminder to change voltage first gpio mode " | each button should be wired the same way, just to different pins. each button needs a 3.3v ran through a 10Kohm resistor and a ground wire, with a final wire with a 10kohm resistor to a gpio pin. Within wiringpi, the pin must be set to input mode. The gpio wire should also be on the opposite side of the 3.3v wire and the ground wire. You made need to switch which pin your wires are connected to if your button is not working properly. You can also check if the button is working by looking at the gpio readall table before and after the button is being pressed, and you should see a change in voltage for that gpio pin (reminder to change voltage first gpio mode " | ||
+ | |||
+ | =====LOGIC===== | ||
+ | |||
+ | **Synopsis: | ||
+ | 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 if our pins are not connected sequentially. | ||
+ | |||
+ | =====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). |