<?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=Control_Led_Brightness</id>
		<title>Control Led Brightness - 版本历史</title>
		<link rel="self" type="application/atom+xml" href="http:///https//wiki.microduino.cn/index.php?action=history&amp;feed=atom&amp;title=Control_Led_Brightness"/>
		<link rel="alternate" type="text/html" href="https//wiki.microduino.cn/index.php?title=Control_Led_Brightness&amp;action=history"/>
		<updated>2026-04-30T00:04:21Z</updated>
		<subtitle>本wiki的该页面的版本历史</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>https//wiki.microduino.cn/index.php?title=Control_Led_Brightness&amp;diff=2696&amp;oldid=prev</id>
		<title>Pkj：Created page with &quot;{{Language | 控制led亮度}} {| style=&quot;width: 800px;&quot; |- | ==Objective== This tutorial will teach you how to control LED's brightness via Processing.  ==Equipment== *'''Mi...&quot;</title>
		<link rel="alternate" type="text/html" href="https//wiki.microduino.cn/index.php?title=Control_Led_Brightness&amp;diff=2696&amp;oldid=prev"/>
				<updated>2014-05-14T13:38:59Z</updated>
		
		<summary type="html">&lt;p&gt;Created page with &amp;quot;{{Language | 控制led亮度}} {| style=&amp;quot;width: 800px;&amp;quot; |- | ==Objective== This tutorial will teach you how to control LED&amp;#039;s brightness via Processing.  ==Equipment== *&amp;#039;&amp;#039;&amp;#039;Mi...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;新页面&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{Language | 控制led亮度}}&lt;br /&gt;
{| style=&amp;quot;width: 800px;&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
==Objective==&lt;br /&gt;
This tutorial will teach you how to control LED's brightness via Processing.&lt;br /&gt;
&lt;br /&gt;
==Equipment==&lt;br /&gt;
*'''[[Microduino-Core]]'''&lt;br /&gt;
*'''[[Microduino-FT232R]]'''&lt;br /&gt;
&lt;br /&gt;
*Other equipment&lt;br /&gt;
**USB cable           one  &lt;br /&gt;
**LED                 one&lt;br /&gt;
**330Ω resistor       one&lt;br /&gt;
**Bread               one&lt;br /&gt;
**Breadboard Jumper   onebox&lt;br /&gt;
&lt;br /&gt;
==Schematic==&lt;br /&gt;
&lt;br /&gt;
[[File:processingControlLEDBrightness原理图.jpg|600px|center|thumb]]&lt;br /&gt;
&lt;br /&gt;
==Program==&lt;br /&gt;
&lt;br /&gt;
https://github.com/Microduino/Microduino_Tutorials/tree/master/Microduino_Processing/LEDBrightness&lt;br /&gt;
&lt;br /&gt;
Note：Don't drop the picture in program&lt;br /&gt;
&lt;br /&gt;
==Debug==&lt;br /&gt;
&lt;br /&gt;
Step 1：Set up hardware system, as follows:&lt;br /&gt;
[[File:processingControlLEDBrightness连接图.jpg|600px|center|thumb]]&lt;br /&gt;
&lt;br /&gt;
Step 2：Explain the code:&lt;br /&gt;
&lt;br /&gt;
The following code's function is that move the mouse on x position, the brightness of picture and LED will change accordingly.&lt;br /&gt;
&lt;br /&gt;
  void draw() {&lt;br /&gt;
    loadPixels();&lt;br /&gt;
  &lt;br /&gt;
    // We must also call loadPixels() on the PImage since we are going to read its pixels.  img.loadPixels(); &lt;br /&gt;
    for (int x = 0; x &amp;lt; img.width; x++ ) {&lt;br /&gt;
      for (int y = 0; y &amp;lt; img.height; y++ ) {&lt;br /&gt;
  &lt;br /&gt;
        // Calculate the 1D pixel location&lt;br /&gt;
        int loc = x + y*img.width;&lt;br /&gt;
  &lt;br /&gt;
        // Get the R,G,B values from image&lt;br /&gt;
        float r = red (img.pixels[loc]);&lt;br /&gt;
        float g = green (img.pixels[loc]);&lt;br /&gt;
        float b = blue (img.pixels[loc]);&lt;br /&gt;
  &lt;br /&gt;
        // We calculate a multiplier ranging from 0.0 to 8.0 based on mouseX position. &lt;br /&gt;
        // That multiplier changes the RGB value of each pixel.      &lt;br /&gt;
        float adjustBrightness = ((float) mouseX / width) * 8.0; &lt;br /&gt;
        r *= adjustBrightness;&lt;br /&gt;
        g *= adjustBrightness;&lt;br /&gt;
        b *= adjustBrightness;&lt;br /&gt;
  &lt;br /&gt;
        // The RGB values are constrained between 0 and 255 before being set as a new color.      &lt;br /&gt;
        r = constrain(r,0,255); &lt;br /&gt;
        g = constrain(g,0,255);&lt;br /&gt;
        b = constrain(b,0,255);&lt;br /&gt;
  &lt;br /&gt;
        // Make a new color and set pixel in the window&lt;br /&gt;
        color c = color(r,g,b);&lt;br /&gt;
        pixels[loc] = c;&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    updatePixels();  &lt;br /&gt;
    &lt;br /&gt;
    //output r value to ledpin&lt;br /&gt;
    arduino.analogwrite(ledPin, int(r));&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
Step 3: Compile the code and download it.&lt;br /&gt;
&lt;br /&gt;
Step 4: The mouse lateral movement on the LED, observe the result.&lt;br /&gt;
&lt;br /&gt;
==Result==&lt;br /&gt;
The mouse is on the left, got the darkest LED, on the right side, got the brightest LED, along with the gradual change from left to right, the effect of the processing as follows:&lt;br /&gt;
&lt;br /&gt;
Mouse on the left：&lt;br /&gt;
[[File:processingOverLEDBrightness1.jpg|600px|center|thumb]]&lt;br /&gt;
Mouse in the middle：&lt;br /&gt;
[[File:processingOverLEDBrightness2.jpg|600px|center|thumb]]&lt;br /&gt;
Mouse on the right：&lt;br /&gt;
[[File:processingOverLEDBrightness3.jpg|600px|center|thumb]]&lt;br /&gt;
&lt;br /&gt;
==Video==&lt;br /&gt;
&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Pkj</name></author>	</entry>

	</feed>