To build a binary counter using LEDs and a raspberry pi
raspberry pie,monitor, keyboard, data cable, hdmi to usb cable, network cable
The Raspberry Pi is a credit-card-sized single-board computer developed in the UK by the Raspberry Pi Foundation with the intention of promoting the teaching of basic computer science in schools.[7][8][9][10][11]
The Raspberry Pi is manufactured through licensed manufacturing deals with Newark element14 (Premier Farnell), RS Components and Egoman. All of these companies sell the Raspberry Pi online.[12] Egoman produces a version for distribution solely in China and Taiwan, which can be distinguished from other Pis by their red coloring and lack of FCC/CE marks. The hardware is the same across all manufacturers.
#include "rpi.h" void clear() { GPIO_CLR = 1 << 7; GPIO_CLR = 1 << 8; GPIO_CLR = 1 << 9; GPIO_CLR = 1 << 10; sleep(1); } int main() { if(map_peripheral(&gpio) == -1) { printf("Failed to map the physical GPIO registers into the virtual memory space.\n"); return -1; } int count = 0; // Define pin 7 as output INP_GPIO(7); OUT_GPIO(7); INP_GPIO(8); OUT_GPIO(8); INP_GPIO(9); OUT_GPIO(9); INP_GPIO(10); OUT_GPIO(10); // Toggle pin 7 (blink a led!) //15 GPIO_SET = 1 << 7; GPIO_SET = 1 << 8; GPIO_SET = 1 << 9; GPIO_SET = 1 << 10; sleep(2); clear(); //14 GPIO_SET = 1 << 7; GPIO_SET = 1 << 8; GPIO_SET = 1 << 9; GPIO_SET = 0 << 10; sleep(2); clear(); //13 GPIO_SET = 1 << 7; GPIO_SET = 1 << 8; GPIO_SET = 0 << 9; GPIO_SET = 1 << 10; sleep(2); clear(); GPIO_SET = 1 << 7; GPIO_SET = 1 << 8; GPIO_SET = 0 << 9; GPIO_SET = 0 << 10; sleep(2); clear(); GPIO_SET = 1 << 7; GPIO_SET = 0 << 8; GPIO_SET = 1 << 9; GPIO_SET = 1 << 10; sleep(2); clear(); GPIO_SET = 1 << 7; GPIO_SET = 0 << 8; GPIO_SET = 1 << 9; GPIO_SET = 0 << 10; sleep(2); clear(); GPIO_SET = 1 << 7; GPIO_SET = 0 << 8; GPIO_SET = 0 << 9; GPIO_SET = 1 << 10; sleep(2); clear(); GPIO_SET = 1 << 7; GPIO_SET = 0 << 8; GPIO_SET = 0 << 9; GPIO_SET = 0 << 10; sleep(2); clear(); GPIO_SET = 0 << 7; GPIO_SET = 1 << 8; GPIO_SET = 1 << 9; GPIO_SET = 1 << 10; sleep(2); clear(); GPIO_SET = 0 << 7; GPIO_SET = 1 << 8; GPIO_SET = 1 << 9; GPIO_SET = 0 << 10; sleep(2); clear(); GPIO_SET = 0 << 7; GPIO_SET = 1 << 8; GPIO_SET = 0 << 9; GPIO_SET = 1 << 10; sleep(2); clear(); GPIO_SET = 0 << 7; GPIO_SET = 1 << 8; GPIO_SET = 0 << 9; GPIO_SET = 0 << 10; sleep(2); clear(); GPIO_SET = 0 << 7; GPIO_SET = 0 << 8; GPIO_SET = 1 << 9; GPIO_SET = 1 << 10; sleep(2); clear(); GPIO_SET = 0 << 7; GPIO_SET = 0 << 8; GPIO_SET = 1 << 9; GPIO_SET = 0 << 10; sleep(2); clear(); GPIO_SET = 0 << 7; GPIO_SET = 0 << 8; GPIO_SET = 0 << 9; GPIO_SET = 1 << 10; sleep(2); clear(); GPIO_SET = 0 << 7; GPIO_SET = 0 << 8; GPIO_SET = 0 << 9; GPIO_SET = 0 << 10; sleep(2); clear(); return 0; }
even though this was a cheesy counter program it was really neat to see the counter work!!