Log into your student account and proceed to the c4eng file: Enter your username and password
“cd” into c4eng with the command:
user@lab46:~$ cd src/fall2024/c4eng
type grabit, followed by c4eng ptb1 to pull the project from the server:
user@lab46:~/src/fall2024/c4eng$ grabit c4eng ptb1
Enter into the ptb1 file. If you're using a raspberry pi, enter into the wiring_pi file. If you're using a pico, enter into the pi_pico file. Access the ptb1.c file and alter accordingly.
The raspberry pi electronics kits came with small, lego-sized, rectangular prism-shaped bars containing 10 independent LED lights. These LED lights are not connected in series or parallel, and each light must be individually wired in order to properly function. The LEDs appear to be red, and the entire bar fits nicely right on the raspberry pi breadboard and occupies 10 adjacent rows. In stl2, we used these bars to create 8 or 10-bit binary counters. In this project, we are using these same bars to create another binary counter, but now we are adding buttons to reverse the order of the lights and begin counting down from the highest number possible.
similar to how we used the buttons in ptb0, we will need to find 2 buttons in our electronics kit which look like little squares with 4 small legs from each corner. To allow for the button to output and give a reading we need to physically hook the button up correctly. You do this by hooking one leg of the button to a direct line to ground. Then, another leg to 3.3v power through a 10 kΩ resistor and a final leg to a gpio pin through another 10 kΩ resistor. Once you have connected this button correctly you can then initialize it to a wpi pin value in the code before using the button. You will need to repeat these steps with another button as for ptb1 you will need 2 seperate buttons one for increasing count and on for decreasing count.
a data structure that allows you store multiple elements of the same data type in the same memory location. Arrays can contain many different date types and even other date structures. Once an array is initialized, it's size cannot be changed. However, you can change date elements at specific points in the array.
int numbers[5] = {1, 2, 3, 4, 5}; //declares and creates an array that contains 5 integers 1,2,3,4,5
int thirdNumber = numbers[3]; //access 3rd data element in the array, which would be 3 in this case.