當前位置:首頁 » 編程語言 » 樹莓派c語言控制

樹莓派c語言控制

發布時間: 2024-11-28 11:17:55

❶ 求教樹莓派用wiringPi控制SPI口的方法,高分!!

#include <stdio.h>
#include <wiringPi.h>
#include <wiringPiSPI.h>
void main(void)
{
int spi1;
unsigned char date[2],rec[2];
int spiChannel = 0;
int clock = 1000000;

wiringPiSetup();
spi1 = wiringPiSPISetup(spiChannel,clock);

if(spi1!=-1)
{
printf("Starting SPI Test\n");
printf("Write:\n");
date[0]=0x80;//寄存器地址
date[1]=0x55;//要寫的數據
wiringPiSPIDataRW(0,date,2);
printf("date[0] : %d ",date[0]);
printf("date[1] : %d \n",date[1]);
delay(500);
printf("Read:\n");
rec[0]=0x00;//寄存器地址
rec[1]=0x00;
wiringPiSPIDataRW(0,rec,2);
printf("rec[0] : %d ",rec[0]);
printf("rec[1] : %d \n",rec[1]);//返回的數據是這個
}
}
我試過可行的,編譯gcc -Wall -o testSPI testSPI.c -lwiringPi
sudo ./testSPI

❷ 樹莓派上用C語言的函數問題

undefined reference to 'digitalwrite'
未定義,你不能直接GCC這個yuke.c ,你的ynke.c 里include 其他的頭文件,你gcc 編譯的時候,要把這些頭文件加入

❸ 如何在windows下或者linux下對樹莓派編程(C語言或C++)

Windows用VS2017,裝上跨平台模塊,新建項目選擇「Linux」,選擇「控制台應用程序」或者「閃爍」,隨後會彈出「Getting Started」教你如何遠程連接上樹莓派,在main.cpp中編寫代碼,F7編譯,Ctrl+F5編譯運行(不調試)。
Linux新建.cpp文件,寫好代碼後保存退出,打開終端輸入 g++ 文件路徑
會生成可執行文件。

熱點內容
outlook郵件的伺服器是什麼 發布:2025-07-15 09:45:59 瀏覽:481
如何安排資產配置 發布:2025-07-15 09:33:24 瀏覽:906
更新傳送伺服器目的地址失敗 發布:2025-07-15 09:27:05 瀏覽:484
c語言else的用法 發布:2025-07-15 09:19:54 瀏覽:119
tnt蘋果核安卓怎麼加好友 發布:2025-07-15 09:05:15 瀏覽:239
年輕人運行內存為什麼比安卓好 發布:2025-07-15 08:52:03 瀏覽:515
怎麼配置組策略 發布:2025-07-15 08:52:02 瀏覽:246
pythonjson格式 發布:2025-07-15 08:42:54 瀏覽:678
醫院葯房要什麼配置 發布:2025-07-15 08:29:55 瀏覽:666
編程說明書 發布:2025-07-15 08:16:39 瀏覽:761