.PS
# UNO.m4
# https://learn.circuit.rocks/the-basic-arduino-schematic-diagram ?
log_init
include(ics.m4)
sinclude(UNO.m4def)
sinclude(../UNO.m4def)
finalscale = 0.72
textht = 0.1/finalscale
textoffset = 1.5bp__ * 2
ifpostscript(,latexcommand({\tiny\sf))

[

 define(`pinlen',`30bp__')
 define(`lg_pinsep',(1.2*lg_pinsep))
 del = lg_pinsep
 define(`pindiam',0.1)

 define(`egnd',`ground(,,E); "GND" at last line.c below')

 U3: ATMEGA16U2
  `"ATMEGA16U2-MU(R)"' at U3.Chip.s below
  `"U3"' at U3.Chip.nw ljust above
 ZU4: ATMEGA328P with .Chip.nw at U3.Chip.sw+(-2.5,-10*del)
  `"ATMEGA328P-PU"' at ZU4.Chip.s below
  `"ZU4"' at ZU4.Chip.nw ljust above

  dot(at U3.Pin2.end)
 R1: resistor(down_ 2*lg_pinsep,,E)
  rlabel(,"R1" rjust "1M" rjust)
  dot
  dot(at R1.start-(2*del,0))
  xtal(down_ 2*lg_pinsep)
  rlabel(,16,"MHz"); dot
 XT2: dot(at last line.start-(2*del,0)); { "XT2" at last [].n above }

 Br1: jumper(left_ from U3.Pin33.end to (XT2,U3.Pin33))
  rlabel(1,,2); llabel(,"GROUND")
 BRE: dot
  line to (Here,U3.Pin28) then to U3.Pin28.end
  {"UGND" at (Br1,Here) above}

 XT1: dot(at XT2-(del,R1.len)); { "XT1" at last [].n above }
  line from XT1 to U3.Pin1.end
  line from U3.Pin2.end to (XT1,XT2)
 C11: capacitor(left_ 3*del); rlabel(,"C11"); llabel(,"22`'pF")
 C9: capacitor(from XT1 to (Here,XT1)); {"C9" "22`'pF" at last [].s+(0,-11bp__)}
  { line to C11.end }
  dot
 G1: egnd
  line from XT1 down_ 3*del; continue to (G1,Here); dot(,,1)
  {"XT3" at last [].n above}
  dot(at Here+(0,-3/2*del),,1); {"XT4" at last [].n above}
  { line to (XT2,Here) then to XT2 chop dotrad_ chop 0 }
  USBVCC: dot(at Here+(0,-7/2*del),,1)
  {"USBVCC" at last [].n-(3/2*del,0) above ljust}
  { line to (Here,U3.Pin31) chop dotrad_ chop 0; continue to U3.Pin31.end }
  dot(at Here+(2*del,0),,1); {"VUCAP" at last [].e+(0,-5bp__) ljust}
  line to (Here,U3.Pin27) chop dotrad_ chop 0; dot
  line from U3.Pin27.end to (G1.x-4.5*del,U3.Pin27.y)
 C8: capacitor(down_ to (Here,Br1)); llabel("C8",,1`\,'\mu)
 Bus1: dot

  dot(at U3.Pin33.end)
  move to U3.Pin3.end; line to (Here,U3.Chip.s)
 G2: ground(,T,E); {"GND" at last line.c below }

 dot(at U3.Pin32.end)
 {line to U3.Pin4.end; dot}
 line left del; ground(,,E,U); {"$+5`\,'$V" at last line.c above}

  line from U3.Pin4.end left_ 2*del
  capacitor(down_ 3*del); { llabel("C7",,100n) }
 G3: ground(,T,E);  {"GND" at last line.c below }

  line from U3.Pin30.end to (G1.x-2*del,U3.Pin30.y); TD: Here
  continue to (Here,U3.Pin32)
  { "RD$-$" above rjust }; continue left_ 1.5*del
 RN3A: resistor(left_ 3/2*dimen_,,E); rlabel(,"22R RN3A")
 Dm: line left_ 7*del

USB: [ K: box invis wid dimen_/2 ht 5*lg_pinsep
  "USB" rjust at K.e
  line thick 1.5 from K.nw to K.ne then to K.se then to K.sw
  foreach_(`x',
   `Pin`'m4Lx: K.ne-(0,m4Lx/5*K.ht)
    "x" at Pin`'m4Lx ljust above',
   1 XUSB, 2 D$-$, 3 D$+$, 4 UGND)
  P_1: K.sw; {"P1" at P_1 below rjust}
  P_2: K.s; {"P2" at P_2 below ljust}
  ] with .Pin2 at Here; "X2" at USB.ne above rjust

  move to U3.Pin29.end
  line to (TD.x-del,Here.y); continue to (Here,Dm-(0,lg_pinsep))
  { "RD$+$" above rjust}
  continue to (RN3A.start,Here)
 RN3D: resistor(left_ 3/2*dimen_,,E); llabel(,"22R RN3D")
  line to USB.Pin3

   dot(at RN3A.end); line to (Here,RN3D)
 Z2: variable(`resistor(down_ to (Here,U3.Pin27),,E); rlabel("Z2")',NN)
   dot(at RN3D.end-(2*del,0))
 Z1: variable(`resistor(to (Here,U3.Pin27),,E); rlabel("Z1")',NN)
   dot; line to (Z2,Here)
   move up Z1.len/4 from last line.c; "CG0603MLC-05E" "X 2"

   line down_ del from USB.P_1; continue to (USB.P_2,Here); dot
   line from USB.P_2 to (USB.P_2,Z1.end) then to Z1.end
   dot(at (USB.P_2,Here)+(3/2*del,0)); line to (Here,USBVCC)
   dot(,,1); {"USHIELD" at last [].n+(4bp__,0) above}

  L1: reversed(`inductor',down_ from Z1.end to (Z1,C8.end),W,,)
   rlabel(,"L1"); llabel("BLM21" ljust); dot
   { dot(at (Z2,Here)); line to (Here,U3.Pin28); dot(,,1)
     "UGND" at last [].n above }
   line from USB.Pin1 to (Z2,USB.Pin1) then up 2*del
  XUSB: dot(,,1); {"XUSB" at last [].n above}
   line from (Z1,USB.Pin3) to (Z1,XUSB);
  DP: dot(,,1); {"D$+$" at last [].n above}
   dot(at (DP,USB.Pin2)-(2*del,0)); line to (Here,XUSB)
  DM: dot(,,1); "D$-$" at last [].n above
   line from USB.Pin4 to (DM,USB.Pin4) then to (DM,BRE) then to BRE

   line from U3.Pin18.end right_ 3.5*del
  JP2: Header(A2,2,4*del,2*lg_pinsep,,0.2;pindiam) with .P3.end at Here
   "JP2" at JP2.Block.nw above ljust
   "2X2M - NM" at JP2.s below
   "1" at JP2.P3.end above ljust; "3" at JP2.P1.end above ljust
   "2" at JP2.P4.end above rjust; "4" at JP2.P2.end above rjust
   line from JP2.P1.end to (JP2.P1.end,U3.Pin19) then to U3.Pin19.end
   dot(at JP2.P1.end); line up 3.5*del
  TPPB5: dot(,,1); {"PB5" at last [].e ljust}
  TPPB4: dot(at TPPB5-(del*3/2,0),,1); {"PB4" at last [].w rjust}
   line to (Here,JP2.P3); dot
   line from JP2.P2.end to (JP2.P2.end,TPPB4)
  TPPB7: dot(,,1); {"PB7" at last [].w rjust}
   line from JP2.P4.end right del*3/2; continue to (Here,TPPB4)
  TPPB6: dot(,,1); {"PB6" at last [].n above}
   line from U3.Pin20.end right del then up del; continue to (TPPB6,Here); dot
   line from U3.Pin21.end up del; continue to (TPPB7,Here); dot

  ICSP1: Header(A2,3,4*del,2.5*lg_pinsep,,0.2;pindiam) \
    with .P1.end at (JP2.P1.end,U3.Pin14)
   "ICSP1" at last [].Block.nw above ljust
   "3X2 M" at last [].Block.sw below ljust
   for_(1,5,2,`"m4x" at ICSP1.P`'m4x.end above ljust')
   for_(2,6,2,`"m4x" at ICSP1.P`'m4x.end above rjust')
   line from ICSP1.P1.end to (ICSP1.P1.end,U3.Pin17) then to U3.Pin17.end
   line from ICSP1.P3.end left del; continue to (Here,U3.Pin15) \
     then to U3.Pin15.end

   dot(at U3.Pin24.end); 
  RN1C: resistor(up_ 5*lg_pinsep,,E); rlabel(,"10K","RN1C"); llabel(5,,3) dot
   line up_ 2*del; ground(,T,E,U); {"+5 V" at last line.w rjust}
   dot(at U3.Pin24.end-(del,0)); 
  D3: diode(up_ RN1C.len); llabel(,,"D3")
   line to (TPPB6.x+del,Here.y)
   continue to (Here,ICSP1.P2.end) then to ICSP1.P2.end
   line from ICSP1.P5.end down 2*del; continue to (TPPB6.x+2*del,Here.y)
   TRESET2: Here
   continue to (Here.x,D3.end.y+del) then to (RN1C.end.x-2*del,D3.end.y+del)
   continue to (Here,U3.Pin24) then to U3.Pin24.end
  G4: ground(at ICSP1.P6.end,,E); {"GND" at last line.c below }
   line from ICSP1.P4.end right del then up U3.Pin16.y-ICSP1.P4.y \
     then to U3.Pin16.end
   dot(at ICSP1.P1.end); line left_ 2.5*del then down_ 5*del
   MISO2: dot(,,1); {"MISO2" at last [].s below }
   dot(at ICSP1.P3.end-(del,0)); line to (Here,MISO2)
   SCK2: dot(,,1); {"SCK2" at last [].s below ljust }
   dot(at TRESET2); line to (Here,SCK2)
   RESET2: dot(,,1); {"RESET2" wid 36bp__ at last [].s below }
   dot(at ICSP1.P4.end+(del,0)); line to (Here,RESET2)
   MOSI2: dot(,,1); {"MOSI2" at last [].s-(del,0) below }

    line right_ del from U3.Pin11.end then up_ del*3/2
   TXLED: reversed(`diode',right_ elen_,LER)
    rlabel(,"YELLOW"); llabel("TX"); dot
    {line up_ del; TPTXL: dot(,,1); "TXL" at last [].n above}
   RN2C: resistor(right_ elen_,,E); llabel(,"1 K RN2C"); rlabel(6,,3); dot 
    line from U3.Pin10.end to (TXLED.start,U3.Pin10)
   RXLED: reversed(`diode',to (TXLED.end,Here),LER)
    rlabel(,"YELLOW"); llabel("RX"); dot
    {line up_ del; dot(,,1); "RXL" at last [].n above}
   RN2B: resistor(right_ elen_,,E); llabel(,"1 K RN2B"); rlabel(7,,2)
    line to (Here,TPTXL); ground(,T,E,U); "+5 V" at last line.c above

# ZU4 connections
   line left_ del*3/2 from ZU4.Pin7.end; dot
   {line up_ del;  G4: ground(,T,E,U); "+5 V" at last line.c above }
  C6: capacitor(down dimen_); llabel("100n",,"C6"); dot
   { dot(at ZU4.Pin8.end) }; dot(at (ZU4.Pin8.end,Here))
  { G4: ground(at Here+(0,-del),,E); {"GND" at last line.c below }
     line to ZU4.Pin22.end }
   line left_ Here.x-C6.x + dimen_*5/4
  C10: capacitor(up_ C6.len); llabel("100n",,"C10"); dot
   { line to (Here,ZU4.Pin20) then to ZU4.Pin20.end }
  L2: inductor(right_ to C6.start,W); rlabel(,"L2"); llabel(,"100$`\,'\mu$H") 

   line left 2*del from ZU4.Pin9.end; PE: dot
  R2: resistor(up_ to (Here,ZU4.Pin10),,E); llabel(,"R2"); rlabel(,"1 M"); dot 
   dot(at Here-(del*4.0,0)); { "XTAL2" above ljust }
  XTAL: xtal(down_ R2.len); llabel("16 MHz"); dot; { "XTAL1" below ljust }
   pushdef(`dimen_',dimen_/2)
   capacitor(left_ del from 0.2 between XTAL.start and XTAL.end)
   capacitor(left_ del from 0.8 between XTAL.start and XTAL.end)
   popdef(`dimen_')
   line up XTAL.len*0.6
   line left del from last line.c then  down del
  G5: ground(,T,E); "GND" at last line.c below
   line down_ del from XTAL.end; dot(,,1); "XT1" at last [].s below
   line up del from XTAL.start;  dot(,,1); "XT2" at last [].n above
   line from XTAL.start to ZU4.Pin10.end
   line from XTAL.end to ZU4.Pin9.end
   line left 2*del from ZU4.Pin1.end; dot
  D2: diode(up_ dimen_); rlabel(,"D2")
   dot(at D2.start-(2.5*del,0))
  RN1D: resistor(up_ D2.len,,E); rlabel("10 K",,"RN1D"); dot
   { line to D2.end }
   line up_ del; ground(,T,E,U); "+5 V" at last line.c above

   line from ZU4.Pin1.end to (RN1D-(1.5*del,0),ZU4.Pin1) then up 7*del
   continue to (ZU4.Chip.w,Here)+(del,0); BRB: dot
   { line down_ 2*del; Br2: jumper(right_ dimen_)
      llabel(1,,2); rlabel(,"RESET\_EN"); line up_ 2*del; dot }
   line right_ dimen_+del
  C5: capacitor(right_ dimen_); llabel(,"C5"); rlabel("100n"); dot
  { RN2D: resistor(down_ dimen_,,E); rlabel(,"1 K"); llabel(,"RN2D")
  G6: ground(,T,E); "GND" at last line below }
  { line up_ del; DTR: dot(,,1); "DTR" at last [].e ljust }
   line from U3.Pin13.end right del/2; continue to (Here,U3.Chip.s) \
     then left+2*del; continue to (Here,BRB) then to C5.end
  TP2: Here; continue to C5.end

   line up 3*del from BRB
  TP1: dot #; line left BRB.x-RN1D.x
  RESET: rswitch( right_ dimen_ from (USB.e,Here)+(del/2,0))
   { "RESET" at RESET+(-del*1.7,1.0*del) above }
   line left del from RESET.start then down del
  G7: ground(,T,E); "GND" at last line.c below

  ICSP: Header(A2,3,4*del,2.5*lg_pinsep,,0.2;pindiam) \
    with .Block.sw at ZU4.Pin19.end+(2*del,del*3)
  "ICSP" at ICSP.Block.nw above ljust
  "3X2 M" at ICSP.Block.sw below ljust
   for_(1,5,2,`"m4x" at ICSP.P`'m4x.end above ljust')
   for_(2,6,2,`"m4x" at ICSP.P`'m4x.end above rjust')
   dot(at ZU4.Pin19.end); line to (Here,ICSP.P3) then to ICSP.P3.end
   line from ZU4.Pin18.end right del; dot
   line to (Here,ICSP.P1) then to ICSP.P1.end
   move to ICSP.P5.end; line to (ZU4.Pin19.end,Here)-(del,0);
   continue to (Here,TP1); dot 
   line from ICSP.P2.end up_ del; ground(,T,E,U); "+5 V" at last line.c above
   line from ICSP.P6.end down_ del; G9: ground(,T,E); "GND" at last line.c below
   move to ICSP.P4.end; line right_ del then down Here.y - ZU4.Pin17.y; dot

   line right_ from RESET.end to (U3.Chip.e+(12*del,0),TP1)
  POWER: Header(A1,8,1.5*del,7*lg_pinsep,,0.2;pindiam) with .P3.end at Here
   "POWER" wid 36bp__ at POWER.Block.nw above ljust
   "8X1F-H8.5" at POWER.Block.sw below ljust
   for_(1,8,1,`"m4x" at POWER.P`'m4x.end above ljust')
   line from POWER.P2.end left del/2 then down POWER.P2.y-POWER.P5.y ; dot
   line from POWER.P4.end left 2.5*del;  "+3V3" above ljust
   dot(at POWER.P3.end-(del*1.5,0)); line up 2*del
   dot(,,1); "RESET" at last [].n above
   line from POWER.P5.end left 3.5*del then up 4*del; ground(,T,E,U)
   "+5 V" at last line.c above
   line left del*2 from POWER.P8.end; "VIN" above ljust
   line left del/2 from POWER.P7.end; dot
   line from POWER.P6.end to (Here,POWER.P6.end) then to Here+(0,-2.5*del)
   G10: ground(,T,E); "GND" at last line.c below
   
   right_

  IOH: Header(A1,10,1.5*del,10*lg_pinsep,,0.2;pindiam) \
    with .P10.end at ZU4.Pin14.end + (del*15,0)
   "IOH" at IOH.Block.nw above ljust
   "10X1F-H8.5" at IOH.Block.se below ljust
   for_(0,9,1,`
     { "incr(m4x)" above ljust at IOH.P`'eval(10-m4x).end }
     move to IOH.P`'eval(10-m4x).start-(pindiam/2+dotrad_/2,0)
     ifelse(m4x,6,,`dot')
     move to IOH.P`'eval(10-m4x).end
     ifelse(eval(m4x<6),1,`line from ZU4.Pin`'eval(14+m4x).end to Here ')
     ifelse(m4x,6,,` line right del*4; dot(,pindiam/2,1) ')
     ifelse(eval(m4x<6),1,`"eval(8+m4x)" at last [].e ljust ')')
   "SCL" at last [].e ljust
   "SDA" at 3rd last [].e ljust
   "AREF" at 5th last [].e ljust

  AD: Header(A1,6,1.5*del,6*lg_pinsep,,0.2;pindiam) \
    with .P6.end at (IOH.P10.end,ZU4.Pin23) #.end + (del*6,0)
   "AD" at AD.Block.nw above ljust
   "6X1F-H8.5" at AD.Block.se below ljust
   for_(0,5,1,`
     dot(at AD.P`'eval(6-m4x).start-(pindiam/2+dotrad_/2,0))
     line from ZU4.Pin`'eval(23+m4x).end \
       to AD.P`'eval(6-m4x).end; {"incr(m4x)" above ljust}
     line right del*4; dot(,pindiam/2,1)
     "A`'m4x" at last [].e ljust ')

  IOL: Header(A1,8,1.5*del,8*lg_pinsep,,0.2;pindiam) \
    with .P8.end at (AD.P1.end,ZU4.Pin2)
   "IOL" at IOL.Block.nw above ljust
   "8X1F-H8.5" at IOL.Block.sw ljust below
   for_(0,7,1,`
     dot(at IOL.P`'eval(8-m4x).start-(pindiam/2+dotrad_/2,0))
     line from ZU4.Pin`'eval(ifelse(eval(m4x<5),1,2,6)+m4x).end \
       to IOL.P`'eval(8-m4x).end; {"incr(m4x)" above ljust}
     line right del*4; dot(,pindiam/2,1)
     "m4x" at last [].e ljust ')

   line from ZU4.Pin21.end up RESET.y-ZU4.Pin21.y-del \
     then right ICSP.P4.end.x-ZU4.Pin21.end.x + 2*del
   continue to (Here,IOH.P3)+(0,del*3/2); dot
   { C4: capacitor(down_ 3.0*del); llabel("C4",,"100n")
     { ground(,T,E); "GND" at last line.e ljust}
     line from IOH.P4.end to (Here,IOH.P4); dot }
   line right del*3/2; continue to (Here,IOH.P3) then to IOH.P3.end

   line left del/2 from IOH.P2.end; continue to (Here,AD.P2); dot
   line left del*3/2 from IOH.P1.end; continue to (Here,AD.P1); dot

   line right_ del*2 from U3.Pin9.end then down_ 3.5*lg_pinsep; dot
   { line right_ 2*del; dot(,,1); "RX" at last [].e ljust }
   line to (Here,RESET)-(0,del)
  RN4B: resistor(down_ dimen_,,E); llabel(7,"RN4B" ljust "1 K" ljust,2)
   line down_ del then left_ Here.x - IOH.P9.end.x + del*2.5
   continue to (Here,ZU4.Pin2); dot

   line right_ del from U3.Pin8.end; dot
   { line right_ 3*del; dot(,,1); "TX" at last [].e ljust }
   line to (Here,RN4B.start)
  RN4A: resistor(down_ dimen_,,E); rlabel(8,"RN4A" rjust "1 K" rjust,1)
   line to (IOH.P9.end,Here)-(del*3.5,0); continue to (Here,ZU4.Pin3); dot

Pwr: [
  Vin: line right 2*del "VIN" above
  RN1A: resistor(down_ dimen_*5/4,,E); rlabel(8, "RN1A" rjust "10 K" rjust ,1)
  CMP: dot
  RN1B: resistor(down_ dimen_*5/4,,E); rlabel(2, "RN1B" rjust "10 K" rjust ,7)
  B12: ground(,T,E); "GND" at last line below

    line right_ 2*del from CMP; dot
    { line up_ 2*del; dot(,,1); "CMP" at last [].n above }
    line right_ del
   POA: opamp(,"+" ljust,"-" ljust) with .In1 at Here
    "U5A" at last [].n; "1" at POA.Out above rjust
    "3" at POA.In1 rjust above; "2" at POA.In2 rjust above
    line left_ del from POA.In2 then down_ del; "+3V3" below
    dot(at POA.Out); {line up_ 2*del; dot(,,1); "GATE" at last [].n above }
   T1: mosfet(down_ dimen_*1.5,R,dMdPyEDSQdB,) with .G at Here 
    "T1" at T1 + (-dimen_/4,del*5/4)
    "FDN340P" at T1 + (0,-del*5/4) rjust
    dot(at T1.S); { line up_ 2*del; ground(,T,E,U); "+5 V" at last line above }
   ] with .RN1B at (USB.e.x+del,RN1C.y-2*del)
   dot(at XUSB+(0,-del/2))
  F1: fuse(right_ to (Pwr.T1.D,Here)); { "500 mA" ljust }
   { "MF-MSMF050-2" at last [].sw below ljust }
   line to Pwr.T1.D

   line from Pwr.T1.S right_ 2.5*lg_pinsep
  { U2:box ht 3*lg_pinsep wid 5*lg_pinsep with .nw at Here+(0,lg_pinsep/2) }
   {"1" above rjust}; {"IN" ljust}
   "LP2985-33DBVR" at U2.s below
   "U2" above ljust at U2.nw
   "3" above rjust at U2.w; line left del from U2.w then up_ lg_pinsep; dot
   "ON/$\overline{\hbox{OFF}}$" at U2.w ljust
  U2P2: U2.w+(0,-lg_pinsep); "2" at U2P2 above rjust; "GND" at U2P2 ljust
   line from U2P2 left del then down_ del
  G15: ground(,T,E); "GND" at last line.c below
  U2P5: (U2.e.x,U2.e.y+lg_pinsep)
   "OUT" at U2P5 rjust; "5" at U2P5 above ljust
   line from U2P5 right 2*del "+3V3" below; dot
   { line up_ del; dot(,,1); "3V3" at last [].n above }
  C3: capacitor(down_ to(Here,G15)); rlabel(,"C3" rjust "1$`\,'\mu$" rjust)
   ground(,T,E); "GND" at last line.c below
   "NC/FB" at (U2.e.x,U2P2.y) rjust

   "SCK" above ljust at Pwr.Vin + (0,4*del)
  line right_ 3*del
  U5B: opamp(,"+" ljust, "-" ljust) with .In1 at Here
   "5" at U5B.In1 above rjust; "6" at U5B.In2 above rjust
   "U5B" at last [].n; "7" at U5B.Out above rjust
   line from U5B.In2 left del then down del then right U5B.Out.x-U5B.In1.x+del
   TD2: dot
   dot(at U5B.Out); dot(at Here+(0,2*del),,1); "LCMD" at last [].e ljust
   line down_ from last [].s to TD2
   RN2A: resistor(right_ dimen_*5/4,,E); llabel(8,"1K",1); rlabel(,"RN2A")
   dot; {line up_ 2*del; dot(,,1); "LL" at last [].n above }
   diode(right_ dimen_*5/4,LE); rlabel(,"YELLOW")
   line down_ dimen_/4; egnd
    
  X1:box ht 3*lg_pinsep wid 5*lg_pinsep with .w at (U2.x,U5B.y+del)
   "X1 DC21MMX" at X1.nw below ljust "PWR SUPPLY" at X1.nw ljust
  X1P1: 1/3 between X1.sw and X1.se; "1" at X1P1 rjust below
  X1P2: 2/3 between X1.sw and X1.se; "2" at X1P2 rjust below
   line down_ del from X1P1; dot; { egnd }
   line right X1.e.x+del - Here.x then up_ X1.e.y-Here.y then to X1.e
   "3" above ljust at X1.e
   line from X1P2 down del/2 then right X1.e.x+del*2 - X1P2.x \
     then up X1.n.y - X1P2.y + del/2; dot
   { line up_ 2*del; PWRIN: dot(,,1); "PWRIN" at last [].w rjust }
  D1: diode(right_ dimen_); llabel(,"D1"); rlabel(,"M7"); dot
  { PC1: capacitor(down_ dimen_,C); llabel(,"PC1" ljust "47$`\,'\mu$" ljust) 
     G16: egnd }
   { line to (Here,PWRIN); dot(,,1); "VIN" at last [].e ljust }
   line right 3*del; { "3" above rjust }
  U1P1: Here
  U1: box ht 3*lg_pinsep wid 4*lg_pinsep with .nw at Here+(0,lg_pinsep/2)  
   "IN" at U1P1 ljust; "OUT" at (U1.e,U1P1) rjust
   "1" below rjust at U1.s
   "U1" at U1.nw +  (0,textht*1.5) above ljust "NCP1117ST50T3G"  ljust
   line from U1.s to (U1.s,G16); egnd
  U1P4: (U1.e,U1P1); U1P2: U1P4+(0,-del)
   { "4" at U1P4 above ljust }; { "2" at U1P2 above ljust }; 
   line right_ 2*del from U1P4; dot;
   line from U1P2 to (Here,U1P2); dot; { line to (Here,U1P4) }
  { PC2: capacitor(down_ to (Here,G16),C)
   llabel(,"PC2" ljust "47$`\,'\mu$" ljust); egnd }
   line right_ del*3/2 from (Here,U1P4); dot
   { line to (Here,PWRIN); ground(,T,E,U); "+5V" at last line.c above }
   line right_ del*3/2; dot; { line to (Here,PC2.start)
    C2: capacitor(down_ to (Here,G16),C)
   llabel(,"C2" ljust "100$`\,'\mu$" ljust); egnd }
   { line to (Here,PWRIN); dot(,,1); "5V" at last [].n above }
   line right_ del*3/2 then to (Here.x+del*3/2,PWRIN.y); dot(,,1)
   "5V1" at last [].n above

] scaled finalscale
#howbox_


ifpostscript(,latexcommand(}%))
.PE
