<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="zh-CN">
		<id>http:///https//wiki.microduino.cn/index.php?action=history&amp;feed=atom&amp;title=Map%28%29</id>
		<title>Map() - 版本历史</title>
		<link rel="self" type="application/atom+xml" href="http:///https//wiki.microduino.cn/index.php?action=history&amp;feed=atom&amp;title=Map%28%29"/>
		<link rel="alternate" type="text/html" href="https//wiki.microduino.cn/index.php?title=Map()&amp;action=history"/>
		<updated>2026-05-02T12:53:26Z</updated>
		<subtitle>本wiki的该页面的版本历史</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>https//wiki.microduino.cn/index.php?title=Map()&amp;diff=15800&amp;oldid=prev</id>
		<title>2016年5月25日 (三) 01:35 Pppeng</title>
		<link rel="alternate" type="text/html" href="https//wiki.microduino.cn/index.php?title=Map()&amp;diff=15800&amp;oldid=prev"/>
				<updated>2016-05-25T01:35:16Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr style=&quot;vertical-align: top;&quot; lang=&quot;zh-CN&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;←上一版本&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;2016年5月25日 (三) 01:35的版本&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l12&quot; &gt;第12行：&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;第12行：&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;参数:&amp;lt;br&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;'''&lt;/ins&gt;参数&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;'''&lt;/ins&gt;:&amp;lt;br&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;*x&amp;#160; 要映射的值&amp;#160; &amp;#160;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;*x&amp;#160; 要映射的值&amp;#160; &amp;#160;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;*in_min&amp;#160; 映射前区间&amp;#160; &amp;#160;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;*in_min&amp;#160; 映射前区间&amp;#160; &amp;#160;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Pppeng</name></author>	</entry>

	<entry>
		<id>https//wiki.microduino.cn/index.php?title=Map()&amp;diff=15799&amp;oldid=prev</id>
		<title>Pppeng：创建页面，内容为“&lt;pre style=&quot;color:green&quot;&gt; long map  ( long  x,     long  in_min,     long  in_max,     long  out_min,     long  out_max     )     &lt;/pre&gt; 等比映射 &lt;br&gt;  将位于...”</title>
		<link rel="alternate" type="text/html" href="https//wiki.microduino.cn/index.php?title=Map()&amp;diff=15799&amp;oldid=prev"/>
				<updated>2016-05-25T01:33:58Z</updated>
		
		<summary type="html">&lt;p&gt;创建页面，内容为“&amp;lt;pre style=&amp;quot;color:green&amp;quot;&amp;gt; long map  ( long  x,     long  in_min,     long  in_max,     long  out_min,     long  out_max     )     &amp;lt;/pre&amp;gt; 等比映射 &amp;lt;br&amp;gt;  将位于...”&lt;/p&gt;
&lt;p&gt;&lt;b&gt;新页面&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&amp;lt;pre style=&amp;quot;color:green&amp;quot;&amp;gt;&lt;br /&gt;
long map  ( long  x,  &lt;br /&gt;
  long  in_min,  &lt;br /&gt;
  long  in_max,  &lt;br /&gt;
  long  out_min,  &lt;br /&gt;
  long  out_max   &lt;br /&gt;
 )    &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
等比映射 &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
将位于[in_min, in_max]之间的x映射到[out_min, out_max].&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
参数:&amp;lt;br&amp;gt;&lt;br /&gt;
*x  要映射的值  &lt;br /&gt;
*in_min  映射前区间  &lt;br /&gt;
*in_max  映射前区间  &lt;br /&gt;
*out_min  映射后区间  &lt;br /&gt;
*out_max  映射后区间 &lt;br /&gt;
&lt;br /&gt;
例如下面的代码中用 map 将模拟量从[0,1023]映射到[0,255]区间:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:green&amp;quot;&amp;gt;&lt;br /&gt;
// Map an analog value to 8 bits (0 to 255)&lt;br /&gt;
void setup() {}&lt;br /&gt;
&lt;br /&gt;
void loop()&lt;br /&gt;
{&lt;br /&gt;
  int val = analogRead(0);&lt;br /&gt;
  val = map(val, 0, 1023, 0, 255);&lt;br /&gt;
  analogWrite(9, val);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
long map(long x, long in_min, long in_max, long out_min, long out_max)&lt;br /&gt;
{&lt;br /&gt;
  return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[https://www.microduino.cn/wiki/index.php/Arduino_%E8%AF%AD%E6%B3%95%E6%89%8B%E5%86%8C/zh 返回Arduino语法手册]]&lt;/div&gt;</summary>
		<author><name>Pppeng</name></author>	</entry>

	</feed>