【发布时间】:2011-12-07 18:52:45
【问题描述】:
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 引脚会发光。
有人可以帮我吗,如何找到将 word 转换为 int 的函数?
【问题讨论】:
标签: c embedded integer type-conversion microcontroller