現在作っているC言語を使用しキャラクタLCDディスプレイに表示させるという作業を行っているのですが。
itoa関数を使用するとエラーが出てうまくコンパイル出来ません。何かいい方法があれば教えていただけないでしょうか。
C言語
1コード 2```#include <stdio.h> 3#include <string.h> 4#include <stdlib.h> 5#include <wiringPi.h> 6#include <lcd.h> 7 8 9int main(int argc, char **argv) { 10 11 int fd; 12 int c; 13 int i; 14 int hp = 100; 15 16 if(wiringPiSetup() == -1) { 17 printf("Setup Fail\n"); 18 exit(1); 19 } 20 fd = lcdInit(2,16,4,4,5,0,1,2,3,0,0,0,0); 21 22 23 lcdClear(fd); 24 lcdPuts(fd,"HP"); 25 26 while(1){ 27 lcdPosition(fd,0,1); 28 char sNum[32]; 29 itoa(hp,sNum,10); 30 lcdPuts(fd,sNum); 31 } 32 33 34 while (1){ 35 printf("0:lcdDisplay test\n"); 36 printf("1:lcdCursor test\n"); 37 printf("2:lcdBlink test\n"); 38 printf("q:End\n"); 39 c=getchar(); 40 if(c == 'q') break; 41 42 if(c == '0') { 43 for(i=0;i<10;i++) { 44 lcdDisplay(fd,0); 45 sleep(1); 46 lcdDisplay(fd,1); 47 sleep(1); 48 } 49 } 50 51 if(c == '1') { 52 for(i=0;i<16;i++){ 53 lcdPosition(fd,i,0); 54 lcdCursor(fd,1); 55 sleep(1); 56 } 57 lcdCursor(fd,0); 58 } 59 60 if(c == '2') { 61 for(i=0;i<16;i++){ 62 lcdPosition(fd,i,1); 63 lcdCursorBlink(fd,1); 64 sleep(1); 65 } 66 lcdCursorBlink(fd,0); 67 } 68 } 69 lcdClear(fd); 70}
回答1件
あなたの回答
tips
プレビュー