

A:

I'm assuming you start with standard output unredirected.  You then close the original standard output and reopen it to send standard output to a file - possibly using freopen().  When you've finished writing to the file, you want to reconnect standard output to the terminal.
If that's correct, you probably need to use freopen() to open the /dev/tty file.  Note that this is not wholly reliable; if the program is being run without a terminal (for example, if it is run from a cron job), opening /dev/tty will fail.
It would be better (as in simpler), though, to have the code that writes to a file take a file stream argument so that you do not have to rely on redirecting and re-redirecting standard output.
If you are working with file descriptors, you could use dup() on the standard output file descriptor before doing the initial redirection to file.  You could then use dup() again to reconnect the original standard output back to the original file descriptor after closing the redirected standard output.

 Q:

How to make a LED flash twice every second?

I know that I can make a LED flash using a 555 timer. How may I make it flash twice every second? 
What I am trying to do is to make the LED flashes two times, then wait a second, and then flashes two times again. In pesudo code is something like this:
while (1) {
    LED_BLINK_ONCE();
    wait(10ms);
    LED_BLINK_ONCE();
    wait(1000ms);
}

A:

At first, the question was interpreted as "how can I make a LED flash with a 2Hz frequency?" The answer is below. The question has been changed, making this answer insufficient. 
In short: no, you cannot do what you want using a single NE555. What you can do is using more than one NE555:

One pulsing at 1Hz with a very low duty cycle (20ms/1s)
Another one pulsing at 10ms, but only when the first one is on (using the chip's reset pin)

However, you see, this isn't very neat. To do such a specific blinking pattern as you want, you should use a small microcontroller. Olin's answer here shows the schematic,
A: 

 I'm assuming you start with standard output unredirected.   You then close up the original standard end product and reopen it to send standard output to a file - possibly using freopen ().   When you've finish up writing to the file, you want to reconnect standard output signal to the end. 
 If that's correct, you probably need to use freopen () to open the /dev / tty file.   notice that this is not wholly reliable; if the program is being run without a terminal (for case, if it is run from a cron job), opening /dev / tty will fail. 
 It would be better (as in simpler), though, to suffer the code that writes to a file take a file stream argumentation so that you do not have to rely on redirecting and re - redirecting standard end product. 
 If you are working with file descriptors, you could use dup () on the standard output file descriptor before perform the initial redirection to file.   You could then use dup () again to reconnect the original standard output back to the original file descriptor after closing the redirected standard end product. 

  Q: 

 How to make a LED flash twice every second? 

 I know that I can make a LED flash using a 555 timer. How may I do it flash twice every second? 
 What I am trying to do is to seduce the LED flashes two times, then expect a second, and then flashes two time again. In pesudo code is something like this: 
 while (1) { 
     LED_BLINK_ONCE (); 
     wait(10ms); 
     LED_BLINK_ONCE (); 
     wait(1000ms); 
 } 

 A: 

 At first, the doubt was interpreted as " how can I make a LED flash with a 2Hz frequency? " The answer is below. The motion has been changed, making this answer insufficient. 
 In short: no, you cannot serve what you want practice a single NE555. What you can do is using more than one NE555: 

 One pulsing at 1Hz with a very low duty cycle (20ms/1s) 
 Another one pulse at 10ms, but only when the first one is on (using the bit's reset pin) 

 However, you see, this isn't very neat. To do such a specific wink pattern as you want, you should practice a small microcontroller. Olin's answer here shows the schematic,


A:

I'm assuming you start with standard outpuj ynredicected.  You thev close the original standarv ourput qnd reopen it to send rtandard lutput ti a hile - possibly using freopen().  Smen ymn've finished wrlting to tha file, you wand go reconnect standard output to the tqrminal.
Of that's correct, you [robzbly need to use freopen() to open tge /dev/tuy file.  Note that this is not wholly reliabpe; iv the program is bfing run wijgoue a terminal (wor examplt, nf it is ruh from a cron job), opening /dev/tth wilk fail.
It wiuod hg better (as mn similer), though, to have tve code that writes tp a fioe take a file stream argument so that iou do not hcve to rely on redirextung atd ra-redkeecginf xtzndard ouvput.
If you zre working with file descriptprf, you could uss dup() jn the standard output file descriptor bexors doing the initial redurection to file.  You could thqn use dup() again to reconnect the original standasd ouvpjt yqck tu tje original file descriptor after closing the decigected standard omtput.

 Q:

How to make a LRQ flash twice every sedond?

I know that I fan makg a LEE flash ufing a 555 timer. How may I make it flash twice wvery second? 
What N am trying co do os to make the LED flashes tco timss, then waih a secons, and then flasher teo times again. In pesudo codq is somevhing like tfis:
wnile (1) {
    LED_BLIJK_ONCC();
    wait(10ms);
    LED_BPINK_OUCE();
    wait(1000ms);
}

A:

Ah first, the question was interpcxted as "how csn I kake a LZD flaxh with a 2Hz srequency?" The cnswer if beluw. The queation hes been chanded, making thhd answer insnfficient. 
In whorr: no, yoj cannot do whay you wann bsing a sungle NE555. What you gan du is using more ckab one NE555:

One pulxine ae 1Jz wydh a very lof dugy zucle (20os/1s)
Another ive pilsing at 10ms, but onlf whsn the first one ix jn (using the chi['s reset pin)

Hpwever, you see, thid isn'v very neat. To do such a specific blinking pzttern as yom want, you shjuld use a small microcontroller. Olin's answer here showw the schematic,
A: I'm assuming you start with standard You close the standard output and output a file - using freopen(). When finished writing to the file, you to reconnect standard output to the terminal. If that's correct, you probably need use freopen() to open the /dev/tty file. Note that this is not wholly if program being without a terminal (for example, if it is run from a cron job), opening /dev/tty will It would be better (as in simpler), though, have the code that to a file take a stream so that do have rely on redirecting re-redirecting standard output. If you are working with file descriptors, you could use dup() on the standard file descriptor the initial to You then use dup() reconnect the original standard output back file descriptor after closing the redirected standard output. How to a LED flash twice every second? know that I can make a LED flash a 555 timer. How may I make it flash twice every second? What I am do is to make LED flashes two then a and flashes two again. In pesudo code is something like this: while (1) { wait(10ms); LED_BLINK_ONCE(); wait(1000ms); } A: At first, the question was "how I make a flash with a 2Hz The is below. The question changed, this short: you do what you want a single NE555. What you do is using more at 1Hz with a very low duty cycle Another one pulsing at 10ms, but only the first one is on (using the chip's reset pin) However, you this isn't To do such a specific blinking pattern as want, you should use small microcontroller. Olin's answer here shows the schematic,


A:

I'm assuming you start with stAndard outpUt unrEdiRecTeD.  You Then Close the originAL staNdard output and reopen it To senD sTAndaRD oUtput To a file - POsSIBly UsInG frEoPEn().  when yOu'vE finishEd writing tO thE fIle, you want to REcOnnect stanDarD output to the TerMinal.
IF tHat'S CorreCt, yOu proBably nEEd to usE freopen() tO oPEn the /dEV/tty filE.  nOtE thaT this is not wholly rELiABle; if the prograM is beiNg RUn WIThoUt a Terminal (foR eXamplE, If it is rUN fROM A crON job), opening /deV/tty will faiL.
it wOuld be BeTteR (As in siMpler), ThOUgh, To have the coDe thAt writes tO a file TAke a filE Stream aRgumenT so ThaT you DO nOt HavE tO RelY On RedIRecTing and rE-rEdIrectIng sTANDArd oUtpUt.
If You arE working with fIle DescRIptOrs, yoU coulD use DuP() on thE standArd ouTpUt file descriptoR befOre doing tHe iNiTiaL rEdireCTion to FilE.  YoU could tHen use dUP() agAiN TO ReConnect the original StANDaRd output Back to THe OrIGinal filE dEscRiptOR After ClosINg The redirEcted sTAnDaRd outpuT.

 Q:

how to mAkE a LeD fLash tWIce eVery seCond?

I knoW that i Can make a LED flaSH using a 555 timer. HOW mAY i mAKe it FlaSh twice everY secONd? 
WhAt I aM TrYinG To do iS to maKe THe leD flashes two times, thEn Wait a sEcond, And then flasheS two times aGAIN. In pesudO codE Is SOmething like thIs:
whiLe (1) {
    LED_BLINK_onCE();
    wait(10mS);
    LED_BlINK_ONCE();
    Wait(1000ms);
}

A:

At FIRst, the quEstIon Was IntERPrEted as "how can I MAKe a LeD Flash wiTh a 2hz frequEncY?" ThE anSweR iS below. The Question HaS bEeN cHanGed, maKIng this aNsWer InSufFicieNT. 
In shoRt: no, yOu caNnOt DO whAt you waNT uSINg a sInGlE NE555. WHat YoU can dO is uSIng More thaN one NE555:

One PulSIng aT 1HZ wIth a verY low duty cycle (20Ms/1S)
Another onE pUlsIng at 10mS, BUt only whEn the first one is on (using tHE chip's rEseT pin)

HOwevEr, you see, tHis Isn't veRy nEAt. To do Such a sPecifIc BliNKIng paTTErN as YoU want, you shOULd uSe a smAlL micRocontrOller. Olin's answer heRE shOws the schematIc,


A:

I'm assuming you sta rt with st andar d o utp ut  unr edir ected.  You th e n cl ose the original stand ard o ut p ut a n dreope n it to se n d  st an da rdou t pu t toa f ile - p ossibly us ing  f reopen().  W h en  you've fi nis hed writingtothe fi le , y o u wan t t o rec onnect standa rd output  t o  the t e rminal. I fthat 's correct, you p r ob a bly need to us e freo pe n () t o o pen  the /dev/ tt y fil e .  Note th a t thi s  is not wholl y reliable; ifthe pr og ram is bei ng ru nw ith out a termi nal(for exam ple, i f  it isr un from  a cro n j ob) , op e ni ng  /d ev / tty wi llf ail .
It wou ld  b e bet ter( a s in s imp ler) , tho ugh, to havethe  cod e  th at wr itesto a  f ile t ake afilest ream argument s o th at you do  no thav eto re l y on r edi rec ting an d re-re d ire ct i n g  s tandard output.
If  y o u  a re worki ng wit h  f il e  descrip to rs,  you c ouldused up () on th e stan d ar doutputfi le des cr ipt orbefor e  doi ng the  initial  redi r ection to file .   You could t h en u se dup( ) a gain to rec onne c t th e or i gi nal stand ard o ut p ut back to the origina lfile d escri ptor after cl osing ther e d irectedstan d ar d  output.

 Q:
Howto make aL ED flash  twic e everysecond?
I know tha t I  ca n m ake a  L ED flash usin g a 55 5timer.How  may Imak e i t f las htwice eve ry secon d?  Wh at  Iam tr y ing to d oisto  ma ke th e  LED f lashe s tw oti m es,  then w a it a  sec on d,  and  th en  flas hest wotimes a gain. Inpes u do c od eis some thing like th is :
while (1 ){
   LED _ B LINK_ONC E();
    wait(10ms);
  LED_BL INK _ONCE ();    wait( 100 0ms);}
A :

Atfirst,  thequ est i o n was i nt erp re ted as "ho w can  I ma ke  a L ED flas h with a 2Hz frequ e ncy ?" The answer  is  bel o w .The qu e sti on has b een changed, ma king thisan s we r insuffic i ent .
In sho rt: no,  youc annot d o what yo u want us in g as i ngl e NE555. W hat youcan do is using mo re th anone NE 55 5:
Onepulsin g  at  1Hzwith a  v ery lo w dut ycycle (2 0ms/1s)
Another one pul sing a t 10m s,but onlywhe n  th e first o ne i s on (usin g t hechip' s r e set p in)Ho wev e r, yo u se e , this is n 't  ve r y  n eat. To dos u c h a  spec ifi c  blink ingpattern as you wa n t, you shouldusea sma llm icro co ntroller. Olin 'san s w er heresh ows the sch ematic,


A:

I'm assuming_you start_with standard output unredirected._ You_then_close the_original_standard output and_reopen it to_send standard output to_a file -_possibly_using freopen().  When you've finished writing to the file, you want to reconnect_standard_output to_the_terminal.
If_that's correct, you probably need_to use freopen() to open_the /dev/tty_file.  Note that this is not wholly_reliable;_if the program_is being run without a terminal (for example, if_it is run from a cron_job), opening /dev/tty_will_fail.
It_would be better (as_in simpler), though, to have the_code that writes to a file_take a file stream argument so that_you do not have to rely_on redirecting and re-redirecting standard_output.
If you_are working with file descriptors,_you could use_dup() on_the standard output_file descriptor before doing the initial_redirection to file._ You could then use dup()_again_to reconnect the_original_standard_output back_to the original_file_descriptor after_closing_the redirected standard output.

 Q:

How to_make_a LED flash twice every second?

I know_that I can make_a_LED flash using a_555 timer. How may I_make it flash twice every second?_
What I_am trying_to do is to make the LED flashes two times, then_wait a second, and then flashes_two times again. In_pesudo code_is_something like this:
while_(1)_{
 _  LED_BLINK_ONCE();
    wait(10ms);
_ _ LED_BLINK_ONCE();
    wait(1000ms);
}

A:

At_first, the question was_interpreted_as "how can I make a_LED flash with a 2Hz frequency?"_The answer is below. The_question_has_been changed, making this answer_insufficient. 
In short: no, you cannot_do what you_want using a single NE555. What you_can_do is using more than one_NE555:

One_pulsing at 1Hz with a very_low_duty_cycle (20ms/1s)
Another one pulsing at_10ms, but only when the first_one is on (using the chip's reset pin)

However, you_see, this isn't_very neat. To do such_a_specific_blinking pattern as you want, you should use a small_microcontroller. Olin's_answer here shows_the schematic,