[英]error with task in microc for pic
char uart_rd;
int b;
void main() {
ANSEL = 0;
ANSELH = 0;
C1ON_bit = 0;
C2ON_bit = 0;
TRISC = 0;
PORTC = 0x00;
UART1_Init(9600);
Delay_ms(10);
UART1_Write_Text("Start");
UART1_Write(10);
UART1_Write(13);
while (1) {
if (UART1_Data_Ready()) {
uart_rd = UART1_Read();
UART1_Write(uart_rd);
**WordtoInt(uart_rd, b)**- this line code is my error
if(b <= 20)
{
PORTC = 0x01;
}
if(b > 20)&&(b <= 40)
{
PORTC = 0x03;
}
if(b > 40)&&(b <= 60)
{
PORTC = 0x07;
}
if(b > 60)&&(b <= 80)
{
PORTC = 0x0F;
}
if(b > 80)&&(b <= 100)
{
PORTC = 0x1F;
}
}
}
}
這是我的任務。 當我構建它時,它向我顯示錯誤。
我讀取0 to 100
數字,表示電池充電,根據電量, port C
0 to 5
引腳會發光。
有人可以幫助我,如何找到將單詞轉換為int的函數?
uart_rd是一個字節的char變量。 b是整數變量。 要將uart_rd轉換為b,請執行以下操作:
b = (int) uart_rd;
簡單來說就是b = uart_rd;
或b = (unsigned char)uart_rd;
?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.