I plugged two leds on digital pin 7/10 on the arduino that are remotely controlled by the raspberry pi when it sends an binary code. I worked on the code, and I can now transmit orders to the arduino from an Raspberry Pi. _nsec = 220000 // value obtained by trial and error to match transmitterįor (int i = 0 i < strlen(szCode) i++) Function to send the output code to the RF transmitter connected to GPIO 7.įor (int iSend = 0 iSend < 10 iSend++) Printf("mmap error %d\n", (int)gpio_map) Gpio_mem += PAGE_SIZE - ((unsigned long)gpio_mem % PAGE_SIZE) If ((gpio_mem = (unsigned char*)malloc(BLOCK_SIZE + (PAGE_SIZE-1))) = NULL) Set up a memory regions to access GPIO ![]() INP_GPIO(7) // must use INP_GPIO before we can use OUT_GPIO Set up gpi pointer for direct register access ![]() #define GPIO_CLR *(gpio+10) // clears bits which are 1 ignores bits which are 0 #define GPIO_SET *(gpio+7) // sets bits which are 1 ignores bits which are 0 Always use INP_GPIO(x) before using OUT_GPIO(x) or SET_GPIO_ALT(x,y) #define GPIO_BASE (BCM2708_PERI_BASE + 0x200000) /* GPIO controller */ Based on the example GPIO in C program by Dom and Gert. ![]() RC Mains socket control program by Geoff Johnson. Code: Select all // g++ -o switch switch.cpp
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |