Difference between revisions of "Lighten Led"

From Microduino Wiki
Jump to: navigation, search
(Created page with "{{Language | 点亮led灯}} {| style="width: 800px;" |- | ==Objective== This tutorial will teach you how to use the Processing to light LED. ==Equipment== *'''Microduino-Co...")
 
 
Line 15: Line 15:
 
**330Ω resistor      one
 
**330Ω resistor      one
 
**Bread              one
 
**Bread              one
**Breadboard Jumper  onebox
+
**Breadboard Jumper  one box
  
 
==Schematic==
 
==Schematic==
Line 31: Line 31:
 
==Debut==
 
==Debut==
  
Step 1:Set up hardware system, as follows:
+
Step 1: Set up hardware system, as follows:
 
[[File:processingControlLED连接图.jpg|600px|center|thumb]]
 
[[File:processingControlLED连接图.jpg|600px|center|thumb]]
  
Step 2:Explain the code:
+
Step 2: Explain the code:
  
 
// Declaring two variable of type PImage, a class available to us from the Processing core library.
 
// Declaring two variable of type PImage, a class available to us from the Processing core library.
Line 68: Line 68:
 
   }
 
   }
  
Step 3:Compile the code and download it.
+
Step 3: Compile the code and download it.
  
  
Step 4:After run, mouse move or click the LED, observe the result.
+
Step 4: After run, mouse move or click the LED, observe the result.
  
 
==Result==
 
==Result==

Latest revision as of 09:00, 13 September 2016

Language: English  • 中文

Objective

This tutorial will teach you how to use the Processing to light LED.

Equipment

  • Other equipment
    • USB cable one
    • LED one
    • 330Ω resistor one
    • Bread one
    • Breadboard Jumper one box

Schematic

ProcessingControlLED原理图.jpg

Program

https://github.com/Microduino/Microduino_Tutorials/tree/master/Microduino_Processing/LEDButtonByOver

https://github.com/Microduino/Microduino_Tutorials/tree/master/Microduino_Processing/LEDButtonByClick

Note:Don't drop the picture in program

Debut

Step 1: Set up hardware system, as follows:

ProcessingControlLED连接图.jpg

Step 2: Explain the code:

// Declaring two variable of type PImage, a class available to us from the Processing core library. PImage LEDON, LEDOFF;

//load two img LEDON = loadImage("LEDON.png"); LEDOFF = loadImage("LEDOFF.png");

Mouse movement will light the LED which was realized in LEDButtonByOver.

Mouse over:

 // When the mouse is moved, the state of the button is toggled. 
 void mouseMoved() {
   if (mouseX > x && mouseX < x+w && mouseY > y && mouseY < y+h) {
     button = true;
   }  
   else {
     button = false;
   }
 }

Mouse click will light the LED which was realized in LEDButtonByClick.

Mouse Click:

 // When the mouse is pressed, the state of the button is toggled.   
 void mousePressed() {
   if (mouseX > x && mouseX < x+w && mouseY > y && mouseY < y+h) {
     button = !button;
   }  
 }

Step 3: Compile the code and download it.


Step 4: After run, mouse move or click the LED, observe the result.

Result

Mouse move on the LED, it will light, and trun off when leave it. Processing'S animation effects:

ProcessingOverLEDON.jpg
ProcessingOverLEDOFF.jpg

Video