Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Register Log in

getchar problem in C

Status
Not open for further replies.

AliBahar

Member level 2
Joined
Feb 4, 2015
Messages
42
Helped
0
Reputation
0
Reaction score
0
Trophy points
6
Activity points
337
Hi
as you know if we use getchar() function it waits for typing char by keyboard.
in my requirement the compiler must return to code and perform the next command line if there is no character typed with keyboard.
so after specified delay time the subsequent command must be performed if if there is no typed character .
any suggestion
 

horace1

Advanced Member level 5
Joined
Nov 18, 2008
Messages
2,123
Helped
596
Reputation
1,188
Reaction score
573
Trophy points
1,393
Location
Norwich, UK
Activity points
13,071
which processor and compiler are you using

some libraries have a function which enables one to check if a character has been received
otherwise you can always check the UART receiver flag yourself
 

andre_teprom

Super Moderator
Staff member
Joined
Nov 7, 2006
Messages
9,181
Helped
1,140
Reputation
2,299
Reaction score
1,116
Trophy points
1,403
Location
Brazil
Activity points
53,323
You can input the value upon some condition like that:


Code C - [expand]
1
2
3
4
if ( kbhit() )
   {     
   variable= getch();    
   }

 

toastedsiopao

Newbie level 4
Joined
Jun 21, 2015
Messages
5
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
19
The problem with kbhit() is that the microcontroller must be in the kbhit(), for it to process the next line, better use an interrupt.
 

Status
Not open for further replies.
Toggle Sidebar

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top